Take the 2-minute tour ×
Stack Overflow is a question and answer site for professional and enthusiast programmers. It's 100% free, no registration required.

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 ?

share|improve this question

1 Answer 1

up vote 2 down vote accepted

$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>
share|improve this answer
    
Or, more ideally, your API should be returning a single object, instead of an object inside an array. –  Cryode Dec 8 '14 at 6:13
    
it worked well without ng-repeat :) –  Oğuz Çiçek Dec 8 '14 at 18:31

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.