0

I have the following code to create a list of radio buttons.

<ul class="bankUl">
        <li *ngFor="let optie of vraag.opties; let i = index" class="{{i}}">
            <label class="image-radio">
                <input type="radio" name="fb" value="{{i}}" [(ngModel)]="_quizService.tmpBank" />
                <img [attr.src]="settings.imagePath + '/banken/' + optie.image" alt="{{optie.name}}">
            </label>
        </li>
    </ul>

Now in my component I have an array like so

var arr = [1,2,3,4]

Now I want to make it so that every li class that is in the array gets hidden. but I dont know where to start. Anyone has an idea?

1
  • what you want to hide which element Commented Aug 17, 2016 at 14:31

3 Answers 3

2

You can use ng-class attribute

ng-class="{'class-name': ([1, 2, 3, 4].indexOf(i) > -1)}"
Sign up to request clarification or add additional context in comments.

Comments

1
<li *ngIf="arr && arr.length>0">

ngIf directive

Comments

0

If you don't want to destroy the object, just hide, and you are using Angular 2+, then:

[hidden]="!arr|| arr.length==0"

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.