Dinesh Kumar
asked on
ng-repeat angular
Experts!
I want to show these values in table using ng-repeat
how can I do it in angular, please help
Thanks
meetDinesh
function storeController($scope, $routeParams, DataService) {
$scope.productsNew = '[{"id":3,"sku":"APL","name":"Apple","description":"Eat one every day to keep the doctor away!","price":20},{"id":4,"sku":"BAN","name":"Banana","description":"These are rich in Potassium and easy to peel.","price":40}]';
}
I want to show these values in table using ng-repeat
how can I do it in angular, please help
Thanks
meetDinesh
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Thanks you so much Neeraj for helping me out there.. I was struggling with it for last 3 days..
and I see json array should not be initialized like following:
$scope.productsNew = '[{"id":3,"sku":"APL","nam e":"Apple" ,"descript ion":"Eat one every day to keep the doctor away!","price":20},{"id":4 ,"sku":"BA N","name": "Banana"," descriptio n":"These are rich in Potassium and easy to peel.","price":40}]';
It generated error so I removed single quotes so its only
$scope.productsNew = [{"id":3,"sku":"APL","name ":"Apple", "descripti on":"Eat one every day to keep the doctor away!","price":20},{"id":4 ,"sku":"BA N","name": "Banana"," descriptio n":"These are rich in Potassium and easy to peel.","price":40}];
and it worked perfectly.
Inspiration taken from your solution :)
and I see json array should not be initialized like following:
$scope.productsNew = '[{"id":3,"sku":"APL","nam
It generated error so I removed single quotes so its only
$scope.productsNew = [{"id":3,"sku":"APL","name
and it worked perfectly.
Inspiration taken from your solution :)
Good to know it helped :)
<body ng-app="myApp" ng-controller="myControlle
...
...
<table >
<tr ng-repeat="p in productsNew">
<td>{{p.id}}</td>
<td>{{p.sku}}</td>
...
...
</tr>
</table>