我有两个SPA:一个有<base href="/">
,另一个有<base href="/dashboard/">
我将这些应用程序部署为tomcat服务器中的单独war
文件。到目前为止,这是有效的。
让我们看看我的代码(第二个应用程序配置,即/ dashboard /):
myApp.config(['$routeProvider','$locationProvider', function($routeProvider, $locationProvider) {
$locationProvider.html5Mode(true);
$routeProvider.when('/events', {
templateUrl: 'event-list/event-list.html',
controller: 'eventListCtrl'
});
$routeProvider.when('/', {
templateUrl: ' ',
controller: ['$scope','$location', function($scope,$location) {
$location.path('events');
$location.replace(); // problem #1
}]
});
$routeProvider.otherwise({redirectTo: '/404'}); // problem #2
}]);
问题#1
正如您在代码中看到的,我希望默认情况下将网址http://localhost/dashboard
重定向到http://localhost/dashboard/events
。但是这种配置在浏览器控制台中给出了最大调用堆栈超出错误。
问题#2
我的第一个应用中已有404页面,即http://localhost/404
位置。但我目前的配置是将我重定向到http://localhost/dashboard/404
。我想重用我的404页面。
请指导我正确的方向。感谢。