Suppose I have configured my route provider as such. There are no controllers configured in my route on purpose.
var module = angular.module('MyModule', [], function ($routeProvider) {
$routeProvider
.when('/home', {templateUrl: 'home.php'})
.when('/page/:someParam', {templateUrl: 'page.php',}).
.otherwise({redirectTo:'/home'});
});
However, I know decide that I need to actually pass the value of :someParam to the server to do "some work"; basically I want the following request to goto my server: page.php?param=<value of :someParam> How would I accomplish this?
Things I have tried:
- referencing :someParam in the templateUrl results in the following query string: page.php?param=:someParam
- injecting $routeParamsProvider into the configuration block (along with $routeProvider). This did not seem to add valuable information, since the route is configured once and this shoudl be dynamic behavior.
- modified the configuration to look like the following. This successfully resulted in the location showing the correct URL, but did not dispatch this URL to the server.
.when('page/:someParam', {
templateUrl: 'page.php',
redirectTo: function(pathParams, path, search) {
return 'page/'+pathParams[someParam]+'/?param='+pathParams[someParam];
}
}
I am well aware that I could limit the users interaction with the link that causes this route change to trigger (through ng-show, or just plain php). I am also aware that I could limit functionality on 'page.php' itself in a controller. Neither of these solutions fit my requirements.
Thank you for any help you can offer!