Search code examples
angularng-class

Multiple classes in ngClass


I'm trying to add multiple values in *ngClass, what used to work on previous alpha releases and doesn't seem to work now on angular2 beta:

<i *ngClass="['fa','fa-star']"></i>

It produces an error:

EXCEPTION: TypeError: Cannot read property 'add' of undefined in [['fa','fa-star'] in PostView@30:27]

What am I missing here?


Solution

  • You should use square brackets to create property binding. See this plunk

    <i [ngClass]="['fa','fa-star']"></i>