title: Get selected items of dynamically created checkbox in angular 2+
body: <p>This is my html. I want to get the value of all selected checkbox when any checkbox is checked or unchecked i.e (change) event fired</p>
  
  <pre><code>&lt;div class="checkbox checkbox-primary" *ngFor="let category of categories; let i = index"&gt;
       &lt;input type="checkbox" id="checkbox_category"  (change)="search(category, $event)" /&gt;
   &lt;/div&gt;
  </code></pre>
  
  <p>This is my search method in angular 2 component :</p>
  
  <pre><code>selectedItems: any = [];
  search( category, event) {
  
     // set selectedItems here
  }
  </code></pre>