Devesh Agrawal Devesh Agrawal - 1 year ago 64
AngularJS Question

when assigning JSON data, not an array error in angularjs

This is my JSON data format.

"0": {
"id": "1",
"image": "/images/brands/surf_excel.png",
"name": "Surf Excel",
"productCount": "6"
"1": {
"id": "2",
"image": "/images/brands/rin.png",
"name": "Rin",
"productCount": "5"
"2": {
"id": "3",
"image": "/images/brands/ariel.png",
"name": "Ariel",
"productCount": "4"

When i am trying to assign this data like this..

$scope.Brands = [];
$scope.Brands = data; // Not an array error

Basically i want to assign data and access one by one.

How to fix this error?

Answer Source

You can use loop for this

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download