lundi 17 juillet 2017

How to show/hide div if last checkbox is checked/unchecked in angular2?

I am working on the angular2 app. In my requirement is create multiple checkboxes using the array and the last checkbox is checked so show the div if the last checkbox is unchecked so hide the div.

Component.ts:-

peoples: any = [
 { "name":"rahul", "status":false},
 { "name":"rija", "status":false},
 { "name":"roy", "status":false},
 { "name":"ninja", "status":false},
 { "name":"riya", "status":false},
 { "name":"rohit", "status":true},
];

component.html

  <div *ngFor = "let people of peoples">
     <input  type = "checkbox" [value] = 'people?.name' [checked] = "people?.status">
      
  </div>

 /****** Hide/show div (if last checkbox is checked so show is div and unchecked so hide this div ******/
 <div>
   <span> Lorem Ipsum is simply dummy text of the printing and typesetting industry. </span>
 </div>




Aucun commentaire:

Enregistrer un commentaire