I have a single page webapp where any request that begins with request for e.g. http://localhost/appname/request*
, the home page is sent back to the client using IIS URL rewrite module.
When Angular receives the webpage, it sees the route. I need to make sure Angular picksup up the routeParams.
Client request : 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('!');
The controller listens to $routeChangeSuccess
.
app.controller('MyCtrl',function($scope){
$scope.$on('$routeChangeSuccess',function(event,routeData,$timeout,$rootScope){
//routeData.pathParams are blank
});
});
Also the URL changes to home page. I.e. I am redirected to http://localhost/appname
.
What I am doing wrong?