Angularjs路线进入无限循环
我的应用程序结合了Angular和.net MVC。假设它加载index.cshtml 页面开始,但它进入无限循环,重新加载_Layout.cshtml页面。我尝试过阅读其他帖子,但我尝试过的一切似乎都不起作用。下面是我的档案 app.jsAngularjs路线进入无限循环,angularjs,model-view-controller,routes,Angularjs,Model View Controller,Routes,我的应用程序结合了Angular和.net MVC。假设它加载index.cshtml 页面开始,但它进入无限循环,重新加载_Layout.cshtml页面。我尝试过阅读其他帖子,但我尝试过的一切似乎都不起作用。下面是我的档案 app.js (function () { 'use strict'; angular.module('sbslsApp', ['ngRoute']) .config(['$routeProvider', '$locationProvider', function ($
(function () {
'use strict';
angular.module('sbslsApp', ['ngRoute'])
.config(['$routeProvider', '$locationProvider', function ($routeProvider, $locationProvider) {
$routeProvider
.when('/', { templateUrl: '/Home/Index', controller: '', title: 'Home Screen' })
.when('/Invoice', { templateUrl: '/Invoice/Index', controller: '', title: 'Invoice List' })
.when('/Invoice/Create', { templateUrl: '/Invoice/Create', controller: '', title: 'Create New Invoice' })
.when('/Invoice/Edit', { templateUrl: '/Invoice/Edit', controller: '', title: 'Edit Invoice' })
.when('/Invoice/Delete', { templateUrl: '/Invoice/Delete', controller: '', title: 'Delete Invoice' })
.otherwise({ redirectTo: '/' });
$locationProvider.html5Mode(true);
}]);
})() 通过将base href设置为“/”而不是document.location,并在TemplateURL前面加上“/”前缀,可以避免无限循环问题
有关详细信息,请参见:嗨,本。我已经将base href设置为“/”,并将templateUrl前缀设置为“/”,但仍然存在这个问题。您是否可以尝试打开开发人员模式并检查以哪个顺序调用哪些页面?后面是“localhost:8080/home/index”您是否能够为每个路由指定单独的控制器?