0

Hi I am passing a username to get a record from the database. In my controller I have

$scope.team=function(data)
team_factory.getMember.query({}, data.username, function(data){
    $scope.team=data;
});

In my factory I have

return {
   getMember: $resource('/api/AuthMember/GetMember/userName', {}, {query: {method: 'GET', isArray: false}})
}

When I run this i get Null back for the response. When I looked in the browser tools factory is passing "userName" as string rather then the value of data.username from controller. Please let me know how I can pass value of data.username to factory. Thanks

2
  • you are missing an apostrophe in the question. Commented Aug 11, 2015 at 4:24
  • I fixed it. That was a typo. Original code is working fine. Just I am not able to pass username to the factory properly. Commented Aug 11, 2015 at 4:30

1 Answer 1

2

try this way.

$scope.team=function(data)

team_factory.getMember.query({username: data.username}, function(data){
    $scope.team=data;
});


return {
   getMember: $resource('/api/AuthMember/GetMember/:userName', {userName:'@username'}, {query: {method: 'GET', isArray: false}})
}

For information please refer this $resource

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.