서버에 편안한 요청을하기 위해 $resource
을 사용하고 있습니다. 내 코드가개체의 속성에 액세스 할 수 없습니다.
service.js
.factory('userServ',function($resource){
return $resource('url/:id',{id:'@id'},{
me: 'GET',isArray:false,url:'url2'}
});
})
나는이
$scope.userDetails = userService.me();
console.log($scope.userDetails) // gives all the details of the user
console.log($scope.userDetails.username) // gives undefined. But username is there in the object
같은 컨트롤러에이 서비스를 사용하고 그래서 어떻게 액세스 할 수있는 객체
서비스 메소드 호출에'.then' 콜백을 넣어야합니다. 콜백 내에 성공과 오류 콜백이 있습니다. –
@PankajParkar 왜 대답을 게시하지 않으시겠습니까? – dfsq