I have a simple angular page:
<tr ng-repeat="client in clients">
<td>{{client.email}}</td>
<td>{{client.role}}</td>
</tr>
In my angular controller i have:
$scope.clients= Restangular.all('clients').getList().$object;
I'm expecting to see the results in the page, but i do not. I tested the service call with a browser plugin, and it works fine(I get JSON back of the clients).
Any idea why this is not working?
If I change me controller to the following, I can see the values of the client:
Restangular.all('clients').getList().then(
function(client) {
for (var i = 0; i < client.length; i++) {
console.log("==>: " + client[i].email + ", role: " + client[i].role);
}
}
);
Do I need to use this second way (with the promise) and build my own "clients" array so that it will be displayed on the angular page?
You can use:
Restangular.all('clients').getList().then(
function(clients) {
$scope.clients = clients;
});
Assuming that you have email and role in your response.