Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/angularjs/23.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
带有angularJS的IIS URL重写模块不工作_Angularjs_Angularjs Routing - Fatal编程技术网

带有angularJS的IIS URL重写模块不工作

带有angularJS的IIS URL重写模块不工作,angularjs,angularjs-routing,Angularjs,Angularjs Routing,我有一个单页webapp,其中任何请求都以请求开始,例如http://localhost/appname/request*,使用IIS URL重写模块将主页发送回客户端 当Angular收到网页时,它会看到路由。我需要确认一下路线图 客户端请求:http://localhost/appname/request/param1/param2 $routeProvider.when('/request/:param1/:param2',{ templateUrl : 'app/views/my

我有一个单页webapp,其中任何请求都以请求开始,例如
http://localhost/appname/request*
,使用IIS URL重写模块将主页发送回客户端

当Angular收到网页时,它会看到路由。我需要确认一下路线图

客户端请求:
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!');
    }

});

如果您正在尝试使用HTML5模式,请查看:谢谢。我被重定向的原因是因为
否则
规则。我并没有做任何改变,但它现在起作用了。此外,我不必将
$routeParams
$scope
一起传递。我在('$routeChangeSuccess',函数(event,routeData){})上使用了
$scope.$on在my
Myctrl
中。