dcdcdc
dcdcdc

Reputation: 263

Displaying object array

Within an angular template I would like to display results if they are available within the object when using ng-repeat.

Example:

[  
    {
       name:"John"
       picture:"john.jpg"
    }
    {
       name:"Tony"
    }
]

At the moment it is displaying an error because I'm trying to get the image on every loop, how can I check if it is available before I use it within the template.

Upvotes: 1

Views: 29

Answers (1)

smnbbrv
smnbbrv

Reputation: 24531

use ng-if to show the image conditionally, e.g.:

ng-if="!!person.picture"

Upvotes: 1

Related Questions