vicky94
vicky94

Reputation: 3

Javascript - How to access the array object in Angular js expression? (ng-repeat)

Javascript

<script>    
var car=[  
  {
   name:'honda',
   color:'red',
   comments:[
    {
     rating:3,
     bidprice:"25,000"
    },
    {
     rating:4,
     bidprice="21,000"
    ]
   }
  ];
</script>

What am i trying to do is getting the bid price of car from each comments by using ng-repeat. I did try like this

<li ng-repeat="car in carList">
  {{car.comments.bidprice}}
</li>

Unfortunately, I getting nothing respond from this code. What should I do? Thanks you.

Upvotes: 0

Views: 45

Answers (2)

ayhan kebeli
ayhan kebeli

Reputation: 11

comments is an array. or you do like this car.comments[0].bidprice or you do another ng-repat="comment in car.comments".

Upvotes: 0

birkett
birkett

Reputation: 10141

<li ng-repeat="comment in car.comments">
  {{comment.bidprice}}
</li>

Should work. I am not sure where you took carList from.

Upvotes: 1

Related Questions