[英]Configure IIS URL Rewrite module for AngularJS HTML5Mode Still Not Working
[英]IIS URL rewrite module with angularJS does not work
我有一个单页webapp,其中任何以请求开头的请求,例如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
。
我做错了什么?
如果我理解正确,则想获取路由参数,但是正确的方法是将$ routeParams注入控制器:
app.controller('MyCtrl',function($scope, $routeParams){
if($routeParams.param1){
alert('SUPER FLY!');
}
});
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.