0
我有一个单独的页面web应用程序,其中的任何请求以请求开始,例如, http://localhost/appname/request*
,使用IIS URL重写模块将主页发送回客户端。带有angularJS的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
});
});
此外,网址更改为主页。即我被重定向到http://localhost/appname
。
我做错了什么?
HTTP://docs.angularjs .org/tutorial/step_07 –
如果您尝试使用html 5模式,请查看:http://stackoverflow.com/questions/16677528/location-switching-between-html5-and-hashbang-mode-link-rewriting –
谢谢。我被重定向的原因是因为'否则'规则。我没有真正做出任何改变,但现在正在工作。此外,我不必传递'$ routeParams'以及'$ scope'。我使用'$ scope。$ on('$ routeChangeSuccess',function(event,routeData){});'在我的'Myctrl'里面。 – lostpacket