2

Hello i use laravel and angular js

im fetching 1 user data from database but i cant show my user data in user profile page

id = $rootScope.user.id

$http.get('api/users/'+id).success(function(data){


    $scope.user = data;


})

i can see the data in chrome developer tools like that :

data: [{id: "308", email: example, first_name: "example", last_name: "example", website: null,…}]
status: 1

but when i want to show data in ng-model like that

ng-model="user.first_name" 

i cant see the data on view

when do this :

ng-model="user"

return is [object Object]

waiting for help guys , where is my problem ?

1 Answer 1

2

$scope.user is an array that contains JSON data. So you can't access first_name like user.first_name. It should help you.

<span ng-repeat="info in user">{{info.first_name}}</span>
Sign up to request clarification or add additional context in comments.

1 Comment

Or, more ideally, your API should be returning a single object, instead of an object inside an array.

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.