0
On this website Andrew Mcgivery I found this very interesting example:
.controller('UserCtrl', function($scope, $stateParams, userService) {
var user = userService.getUser($scope.id);
})
.factory('userService', function($http) {
var users = [];
return {
getUsers: function(){
return $http.get("https://www.yoursite.com/users").then(function(response){
users = response;
return users;
});
},
getUser: function(id){
for(i=0;i<users.length;i++){
if(users[i].id == id){
return users[i];
}
}
return null;
}
}
})
I would like to know how to return all users if you had more than one user with the same id?
C# or Angularjs?
– Jéf Bueno
C#, but if you manage to pass a little of each I am grateful.
– leopiazzoli
But what’s the problem?
– Jéf Bueno
I want to list all items for a particular account, and I’m using a template similar to the example above. Where it checks if the idclient is equal to the idclient within the item table and so can show.
– leopiazzoli
I do not understand your doubt, you can return a list without problems in the same way that returns a record. in this case you will treat something similar to a query with a user, however your application should return a list
– Emir Marques
The application is ASP.NET MVC or Web API 2?
– Leonel Sanches da Silva
Web API 2. Using "Return users[i];" will return a single record, correct?
– leopiazzoli