While filling the form i am sending the id of closedBy
selected item like this
if (selectedClosedPlaces != undefined) {
place.closedBy = selectedClosedPlaces.map(function(g) {
return g._id;
});
} else {
place.closedBy = ['no_name'];
}
i am displaying it in html using {{place.closedBy}}.
i will be having json data like this
[{"_id":"56bc720bd0113ab80dd3cb2d","name":{"en":"fshu","de":"hfasj"},"closedBy":["no_name"],"category":{"_id":"56bb2999f197db040dc3b12b","name":{"en":"asdfdsf","de":"asdf"}}}},
{"_id":"56bc7238d0113ab80dd3cb2e","name":{"en":"jsfadk","de":"jkgdj"},"closedBy":["56bc720bd0113ab80dd3cb2d"],"category":{"_id":"56bb2999f197db040dc3b12b","name":{"en":"asdfdsf","de":"asdf"}}}}]
For the first one it will be null, so i gave some name like ['no_name']
. after adding the first one only i can select closedBy using selectbox.
now i am returning id for the second one. i am having id for the second one in closedBy using, please check the json above. with that id i need to fetch that particular name
Example: i am having 56bc720bd0113ab80dd3cb2d
id with this id i need to show that name.en and name.de =>fshu and hfasj
.
i am using service to get the values
//service code here
.service('PlaceService', function($http) {
return {
init: function(callback) {
$http.get('/api/places').then(function(place_response) {
callback(place_response);
});
}
}
})
and in controller
PlaceService.init(function(place_response) {
$scope.places = place_response.data;
console.log($scope.places); //giving all the places details like the //above json.
console.log($scope.places.closedBy); // Not giving closedBy value here
can anyone please help me