我有一个单页 web 应用程序,其中任何以请求开头的请求,例如http://localhost/appname/request*
,使用 IIS URL 重写模块将主页发送回客户端。
当 Angular 接收到网页时,它会看到路由。我需要确保 Angular 接收到 routeParams。
客户要求:http://localhost/appname/request/param1/param2
$routeProvider.when('/request/:param1/:param2',{
templateUrl : 'app/views/myView.html',
controller : 'MyCtrl',
caseInsensitiveMatch : true
});
$routeProvider.otherwise({ redirectTo: '/' , caseInsensitiveMatch : true });
$locationProvider.html5Mode(true).hashPrefix('!');
控制器监听$routeChangeSuccess
。
app.controller('MyCtrl',function($scope){
$scope.$on('$routeChangeSuccess',function(event,routeData,$timeout,$rootScope){
//routeData.pathParams are blank
});
});
URL 也更改为主页。即我被重定向到http://localhost/appname
.
我做错了什么?