1

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.

1 Answer 1

1

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

ng-if="!!person.picture"
Sign up to request clarification or add additional context in comments.

1 Comment

only ng-if="person.picture" is enough

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.