Reputation: 5494
my API returns this value:
{"id":1,"name":"Test"}
In Angular I did this call to retrieve that value:
$scope.supplier = Suppliers.query({supplierId: $routeParams.id});
But now in my template I do this:
{{supplier.name}}
Even {{ supplier }}
does not give me anything.
but this is empty. Why is this the case?
Thanks!
Upvotes: 0
Views: 38
Reputation: 146
var supplier = Suppliers.query({supplierId: $routeParams.id},{_id:0,name:1});
$scope.supplier=supplier[0].name;
Upvotes: 0
Reputation: 15795
The query function returns a callback, try this:
Suppliers.query({supplierId: $routeParams.id}, function(suppliers) => {
$scope.supplier = suppliers[0];
});
Since query returns a list you need to take only the first from the list.
Upvotes: 1