I am pretty new to Angular UI-ROUTER, I wonder how can I define same URL but with different parameters combination like:
$stateProvider
.state("no_param",{
url: "/param",
/* if no param, goes here*/
template: "<div ng-repeat='p in params'>{{p}}</div>",
controller: function($scope, $stateParams){
$scope.params = $stateParams;
}
})
.state("one_param",{
url: "/param?param1",
/* if one param1, goes here*/
template: "<div ng-repeat='p in params'>{{p}}</div>",
controller: function($scope, $stateParams){
$scope.params = $stateParams;
}
})
.state("another_one_param",{
url: "/param?param2",
/* if one param2, goes here*/
template: "<div ng-repeat='p in params'>{{p}}</div>",
controller: function($scope, $stateParams){
$scope.params = $stateParams;
}
})
.state("two_param",{
url: "/param?param1¶m2",
/* if param1 & param2, goes here*/
template: "<div ng-repeat='p in params'>{{p}}</div>",
controller: function($scope, $stateParams){
$scope.params = $stateParams;
}
})
I tried this, but it does not work. Nothing shown, only display a blank page.
Then I set a breakpoint inside the controller, it turns out that the controller never get run when I navigate to a URL like /param?param2=test
Could anyone help?