Sign up ×
Stack Overflow is a community of 4.7 million programmers, just like you, helping each other. Join them; it only takes a minute:

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.

share|improve this question
    
Can you add your HTML that contains the ng-repeat to the question? – Cerbrus 17 hours ago
    
Sorry, just updated the ng-repeat. I am new to Angular JS. – vicky94 17 hours ago
    
comments is an array. You're going to have to ng-repeat over car.comments – Cerbrus 17 hours ago
    
so what you saying is using <li ng-repeat ="car.comments in carList"> rather than using <li ng-repeat="car in carList"> ? – vicky94 17 hours ago

2 Answers 2

up vote 1 down vote accepted
<li ng-repeat="comment in car.comments">
  {{comment.bidprice}}
</li>

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

share|improve this answer
    
<li ng-repeat="bidprice in car.comments"> {{bidprice.bidprice}} </li> are we able to do like this? I am not sure how to declare. – vicky94 16 hours ago
    
Yes that should work, but I would use 'comment' since you are looping through comments – xbirkettx 16 hours ago
    
Thanks you so much. The problem is resolved. – vicky94 16 hours ago

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

share|improve this answer
    
Yeah, i try car.comments[0].bidprice before but if i want using ng-repeat to get all the bid price rather than type two times car.comments[0].bidprice and car.comments[1].bidprice. Sorry for poor english. – vicky94 17 hours ago
    
vicky do you have one car with many comments that you want to display or do you have N cars and you want to display for each car its comments? – ayhan kebeli 16 hours ago
    
Yeah I only got one car with many comment and inside the comments got bidprice this attribute. I am trying to use ng-repeat to display all the bidprice.Thanks you. – vicky94 16 hours ago
    
vicky then, your car above is an array but it isn't right like this, so your car trasform in a object(var car={....}) and then try this: <li ng-repeat="comment in car.comments"> {{comment.bidprice}} </li> – ayhan kebeli 16 hours ago
    
Thanks you. I did try "comment in car.comments", its work well! – vicky94 16 hours ago

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.