0

I have this object

people = [{name: "John", registered: true },{name: "Micky", registered: false },{name: "Carol", registered: true }]

and I have this angular HTML:

<ul>
  <li ng-repeat="person in people">
    {{person.name}}
    <div class="already-registered-icon">&nbsp;</div>
  </li>
</ul>

My question is - how do I make a condition to display the registered icon only when the user is already registered?

I would think of something like this (but I don't know how it can be written):

{{if person.registered}}
        <div class="already-registered-icon">&nbsp;</div>
{{end}}
2
  • Check the docs. But if you want to go on guessing, I'd go for #if. Commented Jan 21, 2013 at 14:45
  • The docs. Commented Jan 21, 2013 at 14:46

2 Answers 2

2

Just use ngShow:

<div ng-show="person.registered" class="already-registered-icon">&nbsp;</div>

demo: http://jsbin.com/usodaw/1/

Sign up to request clarification or add additional context in comments.

2 Comments

this solves my issue (assigning display:none) but is there an attribute that will not render the HTML itself at all if the condition is true?
@Alon I don't know a build-in solution. You could probably write your own directive, though. But I'm not sure if this is the right approach.
0

It was the ng-show attribute I was missing

<ul>
  <li ng-repeat="person in people">
    {{person.name}}
    <div ng-show="person.registered" class="already-registered-icon">&nbsp;</div>
  </li>
</ul>

Comments

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.