/api/users/:id
users tablomda seçtiğim bir user ın bilgilerine erişmek istiyorum. Nasıl çekebilirim?
app.controller('YourController', function($scope, UsersService) {
.................
UsersService.getById(userId, function() {
$scope.users = ???;
}, function(errResponse){
console.error('Error while fetching Users');
}
);
Bu kısımda eğer getById bir veri dönüyor ise, aksi taktirde data gelmeyince ne alınır değil mi!. Başarılı şekilde veri çekilebiliyor ise, gelen datayı “information” değişkenine atıyoruz. herhangi bir isim olabilir sanıyorum. Bunun .data diyerek içindeki veriyi almış oluyor ve users a setlemiş oluyoruz.