How do I show only the first element in angular?
I\'m using ng-repeat
like this:
Don't use ng-repeat directive, this should work:
<div>{{ products[0].price }}</div>
Alternately you can show the last in an array by doing this:
<div>{{ products[products.length-1].price }}</div>
You can use this:
<div ng-bind="products[0].price"></div>
It will use the first element of the array.
You might also want to use
<div ng-repeat="product in products|limitTo:1">
<div>{{ product.price }}</div>
</div>
but yes the code below is better
<div>{{products[0].price}}</div