ngClass中的多个类 [英] Multiple classes in ngClass

查看:329
本文介绍了ngClass中的多个类的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试在* ngClass中添加多个值,该值曾经在以前的alpha版本中可用,而现在似乎在angular2 beta中不起作用:

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>

它产生一个错误:

例外:TypeError:无法读取未定义的属性添加" [['fa','fa-star'] in PostView @ 30:27]

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

我在这里想念什么?

推荐答案

您应使用方括号创建属性绑定.参见此小品

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

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

这篇关于ngClass中的多个类的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆