user13286
user13286

Reputation: 3075

Angular format for an array within an array?

I am just getting started with Angular and I have run into an issue with my app.js where I have an array within an array. I would like to create an array for coordinates within my product array which I currently have set up like this:

var products = [{
    name: "Product 1",
    description: "",
    coords: [
        {
            top: 683,
            left: 626
        },
            top: 926,
            left: 600
        },
            top: 320,
            left: 750
        }
    ],
    videos: "video1"
}, {
    name: "Product 2",
    description: "",
    coords: [
        {
            top: 356,
            left:580
        },
            top: 600,
            left: 166
        },
            top: 470,
            left: 590
        }
    ],
    videos: "video2"
}];

When I have the coords array in app.js, my HTML is not rendering(just shows the angular expressions), but when I remove the coords array, it renders correctly. I am not currently doing anything with the coords, they're just there for future use, would that prevent the HTML from rendering correctly, or is there some sort of formatting issue?

Upvotes: 0

Views: 120

Answers (1)

Aswin Ramesh
Aswin Ramesh

Reputation: 1674

your property coords is wrong format

coords: [
        {
            top: 356,
            left:580
        },
            top: 600,
            left: 166
        },
            top: 470,
            left: 590
        }
    ],

it misses the {

  coords: [
        {
            top: 356,
            left:580
        },{
            top: 600,
            left: 166
        },{
            top: 470,
            left: 590
        }
    ],

Upvotes: 2

Related Questions