title: Changing color of tag-input dynamically angular2
body: <p>I want to send invitation email to the users from UI. I need to type multiple email ids of those users which are not already part of our system. I'm using angular2's tag-input for it. Everything is working fine except some validation.
  After typing email, I'm checking whether user is already exist in the system or not. If the user is exist, then I want that email tag to be highlighted as red. So at the end all the emails which are already present in the system, should have red color for their tags.</p>
  
  <p>Following is my component:</p>
  
  <pre><code>  public validateEmail(item: any): string {
      if(item.includes("@") &amp;&amp; item.includes(".")) {
        return `${item}`;
      }
    }
  
    public onAdd(item: any) {
      this.userService.getUserByEmail(item).then(
        (response: any) =&gt; {
          this.users = response;
          if(this.users.length === 0) {
            this.canSend = true;
            this.emails.push(item);
          } else {
            this.errorItem = item;
            this.isError = true
            this.canSend = false;  
          }
        }
      ).catch(
        (error: any) =&gt; console.log(error)
      )    
    }
  
    public onRemove(item: any) {
      let index = this.emails.indexOf(item);
      this.emails.splice(index, 1);
      if(item === this.errorItem)
      {
        this.isError = false;
        this.errorItem = ""
        this.canSend = true;
      }
    }
  </code></pre>
  
  <p>Below is HTML code:</p>
  
  <pre><code>&lt;md-card class="default-card"&gt;
    &lt;h2&gt;{{ 'invitation' | translate}}&lt;/h2&gt;
  &lt;/md-card&gt;
  
  &lt;md-card class="default-card"&gt;
    &lt;div&gt;
      &lt;md-hint class="error-hint"&gt;
        &lt;span *ngIf = "isError"&gt;{{'Please remove email: ' | translate}}{{errorItem}}&lt;/span&gt;
      &lt;/md-hint&gt;
      &lt;tag-input [ngModel]="emails"
                 separatorKeys="[32]"
                 (onRemove)="onRemove($event)"
                   (onAdd)="onAdd($event)"
                 [transform]="validateEmail"
                 [secondaryPlaceholder] ="('Enter email ids' | translate)"
                 [placeholder]="('+ Email')"&gt;
      &lt;/tag-input&gt;
    &lt;/div&gt;
  &lt;/md-card&gt;
  &lt;div class="send-invite-wrapper"&gt;
    &lt;div class="fill-send-invite"&gt;&lt;/div&gt;
    &lt;button md-raised-button color="primary" class="save" [disabled] = "!canSend || isError"
            (click)="sendInvite()"&gt;{{'send invitation' | translate}}
    &lt;/button&gt;
  &lt;/div&gt;
  </code></pre>