AngularJS - Can I use data binding value depending on ternary operator

梦想的初衷 提交于 2019-11-30 17:59:02

You can do this

{{ object1.hidden && 'Minimize' || 'Maximize' }}

In angular 1.2 a real ternary operator will be added.

With the release of angular 1.2, you can now use the more intuitive ternary operator inside ng-bind

<a ng-bind="object1.hidden ? 'Maximize' : 'Minimize'"></a>

or inside brackets

<a>{{ object1.hidden ? 'Maximize' : 'Minimize' }}</a>
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!