vendredi 25 août 2017

Angular 4 - Add Class if ngModel is not empty

How can I add a class to an element on a page if my defined ngModel for a select element is not empty. Currently have this..

<md-select placeholder="Location" name="location" [(ngModel)]="selectedLocation">
      <md-option *ngFor="let option of locationOptions" [value]="option.value">
        
      </md-option>
    </md-select>

And would like to add a class to a span element if the ngModel is not empty, something like this...

<p>Location:<span ng-class="{'complete': selectedLocation.length > 0}"></span></p>

Aucun commentaire:

Enregistrer un commentaire