Reputation: 23
There is code of mine $stateProvider:
$stateProvider
.state("home", {
url: "/",
template: "<employee-info-component user='$resolve.user'></employee-info-component>",
resolve: {
user: function(individualFootprintService) {
var usr = individualFootprintService.getCurrentUser();
return usr.then(function(data) {
return data;
});
}
}
It's my service:
function getCurrentUser() {
return $http
.get("/user")
.then(function(response) {
return response.data;
});
}
This is my binding in component:
binding:{
user: '<'
}
We tried this controller:
function individualFootprintController(user) {
var $ctrl = this;
user.then(function (data) {
$ctrl.user = data;
});
}
But we are receiving exception
Error: [$injector:unpr] Unknown provider: userProvider <- user <- individualFootprintController
And we tried this controller:
function individualFootprintController() {
var $ctrl = this;
console.log($ctrl.user);
}
But user
don't comes to the controller and its value is undefined
.
So my question is how can i get access to the desired object from the controller?
Upvotes: 2
Views: 311