离子条件类CSS [英] Ionic conditional class css

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

问题描述

我正在使用Ionic3,并且具有:

I am using Ionic3, and have:

<span class="char-left">{{REVIEW_MAX_LENGTH-ratingModel.review.length}} characters left</span>

当要填充另一个值时,即ratingForm.controls.review.length > 0将值更改为class="char-left-error"时,我想有条件地更改class值.

I would like to conditionally change the class value when another value is populated, i.e when ratingForm.controls.review.length > 0 change the values to class="char-left-error".

我确实查看了 ng-class ,但似乎无法使其正常工作.

I did look at ng-class, but cannot seem to get it to work.

任何帮助表示赞赏.

推荐答案

如果仅是一个类,则可以尝试

If it's just a single class, you can try with

<span class="char-left" [class.char-left-error]="ratingForm.controls.review.length > 0">

通过使用 ngClass ,它将看起来喜欢

By using ngClass it would look like

<span class="char-left" [ngClass]="{'char-left-error' : ratingForm.controls.review.length > 0}">

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

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