AngularJS纳克级的多个条件 [英] AngularJS ng-class multiple conditions

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

问题描述

我想一个特定的类适用于如果2个条件,则一个li元素,所以我写了下面code,但它似乎并不奏效

I am trying to apply a specific class to an li element if 2 conditions are true, so I wrote the following code but it is not seem to be working

ng-class="{current:isActive('/'), loginStatus: false}"

有人能告诉我什么,我做错了,因此所应用的类仅途径是在/和loginstatus是假的怎么办啊?谢谢

Can someone please tell me what I am doing wrong and how to fix it so that the class is applied only if route is at / and loginstatus is false? Thanks

推荐答案

关键应该定义你想要的类,剩下的应该是前pression评估,从而决定是否显示类...

The key should define the class you want, and the rest should be the expression to evaluate, which determines if the class is shown...

ng-class="{current:isActive('/') && loginStatus === false}"

什么你说的更像是...设置类电流如果 isActive('/')和还设置类 loginStatus 如果是真实的。

What you were saying was more like... set class current if isActive('/') and also set class loginStatus if false is true.

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

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