2015-02-09 86 views
0

我的应用将Angular与.net MVC结合在一起。它假设在开始时加载index.cshtml 页面,但它会进入无限循环重新加载_Layout.cshtml页面。我尝试阅读其他帖子,我尝试过的一切似乎都不起作用。下面是我的文件Angularjs路由进入无限循环

app.js

(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); 
}]); 

})();

回答

0

通过将base href设置为'/'而不是document.location并将templateUrls加上'/'前缀,可以避免无限循环问题。

有关详细信息,请参阅:AngularJs Infinite Loop

+0

嗨本。我已经将基础href设置为'/',并且使用'/'作为前缀templateUrl,但仍然会出现该问题 – wodubayo 2015-02-09 06:38:51

+0

您可以尝试打开“开发人员”模式并检查在哪个页面中调用哪个页面? – Jinith 2015-02-09 06:43:22

+0

首先调用根,即http:// localhost:0808/ – wodubayo 2015-02-09 06:51:23