Reputation: 89
I am working on an angular application.
In the current build - there is a controller that gets invoked when a user presses a button - it opens up a modal window and populates the contents as such.
I am trying to remove the modal and reconfigure the application, so that it goes to a new page
The first page is a list of people /people
When you click a person, it will go to a page like /people/view/34323
I am trying to configure the app stateprovider stack like this:
$stateProvider
.state('people-view', {
url: "/people/view/:id",
templateUrl: "partials/people/people-view.html",
controller: personDialogController,
resolve: {
politicservice:function(personservice){
personservice.getPolitics(id).then = persondata.data;
}
biography:function(personservice){
personservice.getBio(id).then = persondata.data;
}
dialogueId:function(personservice){
//id
}
}
})
This will create the basic page...but the services that used to work for this controller now don't.
It's as if the id is not being passed into the resolve functions and it's as if the persondata
then
, the promise is not calling back?
Upvotes: 1
Views: 66
Reputation: 22911
Pass $stateParams
to the resolve function:
$stateProvider
.state('people-view', {
url: "/people/view/:id",
templateUrl: "partials/people/people-view.html",
controller: personDialogController,
resolve:
politicservice:function(personservice, $stateParams){
return personservice.getPolitics($stateParams.id);
}
biography:function(personservice, $stateParams){
return personservice.getBio($stateParams.id);
}
dialogueId:function(personservice, $stateParams){
//$stateParams.id
}
})
$stateParams
will contain an object of all the parameters as defined in the url string. See this question for more information.
Upvotes: 1