所以我正在开发一个使用 AngularJS 和用 VB.NET 编写的 Web API 的项目
所有这些工作都很好,直到我们必须维护路由为止。
以下代码来自我的 angularApp,它定义了路由。
var angularApp = angular.module('AngularApp', ['ngRoute']);
angularApp.config(['$routeProvider',
function ($routeProvider) {
$routeProvider
.when('/ExpenseOverview', {
controller: 'ExpenseOverviewController',
templateUrl: 'Angular/Views/ExpenseOverview.aspx'
})
.when('/AddExpense',
{
controller: 'AddExpenseController',
templateUrl: 'Angular/Views/AddExpense.aspx'
})
.when('/ApproveExpense',
{
controller: 'AddExpenseController',
templateUrl: 'Angular/Views/ApproveExpense.aspx'
})
.when('/Organogram', {
controller: 'AddExpenseController',
templateUrl: 'Angular/Views/Organogram.aspx'
})
.when('/AddType', {
controller: 'AddExpenseController',
templateUrl: 'Angular/Views/AddType.aspx'
})
.when('/ExpenseEvidence', {
controller: 'AddExpenseController',
templateUrl: 'Angular/Views/ConfirmExpenseEvidence.aspx'
})
.otherwise({ redirectTo: '/ExpenseOverview' });
}]);
EDIT 我使用 .aspx 页面是因为我想使用一些隐藏代码。如果需要,我会将它们更改为静态 HTML 文件。
Everything works fine on startup, the routing works as it was programmed to.
Next to that, when I navigate to other pages, the routing still works like expected.
但从那时起,当我使用 Chrome 的后退按钮导航回主窗体时,一切都崩溃了。
When I click on this button to navigate to another page (label is in Dutch), the routing isn't even triggered. This button is a simple HTML5 button and I also tried with a simple tag. It just triggers a postback (sort of, the screen flashes for a second) and nothing happens.
So in an attempt to reset everything, I tried to reload the page and this is what becomes of my URL:
导航到另一个页面后,它只是更改了“#/???”我的 URL 的一部分,这基本上意味着我的路由完全改变了,我不知道是什么原因造成的。
谁能详细说明这个问题吗?也许是关于我做错了什么的解释?如果是因为 .aspx 页面,我需要找到一个关于如何在以 HTML 编写的视图上使用 ResourceFiles 的解决方案。