Reputation: 77
View has controls for selecting cities and selecting params. And this view show selected objects for the selected cities. When view is loaded I parse the url and do request to the server. Url for the view are some as: http://example.com/cities?cityId=3&cityId=33¶m1=value1. My questions:
Upvotes: 0
Views: 382
Reputation: 77
Url generating automatically by $state.go('cities', {/* params */}, {location: true}).
In controller I put handler in $scope.$on('$stateChangeSuccess'..
Upvotes: 1
Reputation: 3783
You can generate URL with
$location.url('cities?cityId=3¶m1=value1');
and You can handle this in your router config $stateProvider
where you define states
.state('cities', {
url: "/cities?cityId¶m1",
templateUrl: "....",
controller: "citiesController"
})
// will match to url of "/cities?cityId=[any id]¶m1=[any value]"
and finally You can have these parameters in the citiesController.js i.e
console.log($stateParams);
//Object {cityId: "3", param1: "value1"}
Hope it helps.
Upvotes: 2