title: How to remove duplicate value in an array Angular 2
body: <p>I have checkbox (with selected value by user, checked ). So I need to edit this checkbox and get all the selected value into an array and send it to post.<br></p>
  
  <p><strong>Html<br></strong></p>
  
  <pre><code>&lt;div *ngFor="let item of officeLIST"&gt;
    &lt;div *ngIf ="item.officeID== userdata.officeID"&gt;
         &lt;input #office type="checkbox" id="office" name="office" class="form-control" value="{{item.officeName}}" checked (click)="officeSelection($event,$event.target.value)" &gt; {{(item.officeName== "" ? "--No data--" : item.officeName)}} 
   &lt;/div&gt;
    &lt;div *ngIf ="item.officeID!= userData.officeID"&gt;
       &lt;input #office type="checkbox" id="office" name="office" class="form-control" value="{{item.officeName}}" (click)="officeSelection($event,$event.target.value)"&gt; {{(item.officeName== "" ? "--No data--" : item.officeName)}}
   &lt;/div&gt;
  &lt;/div&gt;
   &lt;button type="button" class="btn btn-primary"(click)="updateOffice(userData.officeID)"&gt; Save &lt;/button&gt;
  </code></pre>
  
  <p><strong>Click function (to add selected value and to remove unselected  value)</strong></p>
  
  <pre><code> officeSelection(event: any, value) {        
  
          if (event.target.checked === true)
          {
                 this.officeArray.push(value);
          } 
          else {
              this.officeArray.splice(this.officeArray.indexOf(value), 1);
  
          }
      }
  </code></pre>
  
  <p><strong>Update Function</strong></p>
  
  <pre><code>updateOfficeDetail(officeid) {
  
  if(officeid= 1)
  {    
           this.officeArray.push('stars dept');
  }   
  else if(officeid= 2)
  {            
  
           this.officeArray.push('moon dept');
  }
  else
  {          
       this.officeArray.push('Sun dept');
  
  } 
  </code></pre>
  
  <p>}</p>
  
  <p><strong>Problem is</strong>
  if I update the data without changing current value of checkbox,eg: sun dept, <br> this <strong>sun dept</strong> will be <strong>push</strong> into <strong>officeArray</strong> . <br>
  but if again I want to update the data by editing the checkbox(choose another value), so the previous selected value and current selected value will be push into this officeArray
  <br>
  if user did not edit the checkbox (just proceed with current selected value)>>>> the officeArray will look like this</p>
  
  <blockquote>
    <p>["sun"]<br>
    <strong>and if the user tried to update the checkbox by clicking one more checkbox, the array will look like this</strong><br>
    ["sun","moon","sun"]</p>
  </blockquote>
  
  <p>I just want ["sun","moon"] in the officeArray. should i remove? or clear something? <br></p>
  
  <p>I tried to do some research and a lot questions similar to me. but somehow all the solutions did not work for me. any idea?</p>
  
  <p>Thank you</p>