Multiple classes in ngClass

Sagi  picture Sagi · Dec 29, 2015 · Viewed 29.5k times · Source

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?

Answer

alexpods picture alexpods · Dec 29, 2015

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

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