Re: Angular 2 Typescript ngClass doesn't work when hyphen is used.

154 views
Skip to first unread message
Message has been deleted

Sander Elias

unread,
Mar 3, 2016, 2:21:17 AM3/3/16
to AngularJS
Hi Ruchi,

More of an JS problem then an angular one. Try this:

<div [ngClass]="data['status-circle']"></div>

Object notation does not work if you have special characters in your names. Switching to array notation solves this.

Regards
Sander

Ruchila Baruah

unread,
Mar 3, 2016, 4:02:24 AM3/3/16
to ang...@googlegroups.com

Hi Sander, this still doesn't solve the problem. The object contains status but CSS has status-circle. I wonder how this binding would work.

--
You received this message because you are subscribed to a topic in the Google Groups "AngularJS" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/angular/zvMEO3TSIFY/unsubscribe.
To unsubscribe from this group and all its topics, send an email to angular+u...@googlegroups.com.
To post to this group, send email to ang...@googlegroups.com.
Visit this group at https://groups.google.com/group/angular.
For more options, visit https://groups.google.com/d/optout.

Ruchila Baruah

unread,
Mar 3, 2016, 4:11:14 AM3/3/16
to ang...@googlegroups.com

Can you give me an example of how this should work ?

Sander Elias

unread,
Mar 3, 2016, 7:09:32 AM3/3/16
to AngularJS
Hi Ruchi,

you mean something like this?

<div [ngClass]="data['status-circle']+'-circle'"></div>


Ruchila Baruah

unread,
Mar 3, 2016, 7:22:24 AM3/3/16
to ang...@googlegroups.com

No but
[ngClass] = "data.status + '-circle' " did work. Thank you so much for your help. :)

Reply all
Reply to author
Forward
0 new messages