angularjs 1.4中的一种方法绑定 [英] One way binding in angularjs 1.4
本文介绍了angularjs 1.4中的一种方法绑定的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
使用新语法就像用::开头表达式一样容易.因此,如果我们将一次性表达式应用于上面的示例,我们将对此进行更改:
Using new syntax is as easy as starting an expression with ::. So if we apply the one-time expression to our example above, we change this:
<p>Hello {{name}}!</p>
对此
<p>Hello {{::name}}!</p>
现在它是一种绑定方式.
and it is now one way binding.
但是,当使用诸如ng-class之类的角度指令时,如何创建一次性绑定?我尝试了以下操作,但没有成功:
But how can we create a one time binding when using angular directives such as ng-class? I tried the following, but it did not work:
ng-model="::name"
ng-class="['label',{'label-danger': 'High' == ::tsk.Priority}]:
推荐答案
在此处回答我的问题 http://toddmotto.com/angular-one-time-binding-syntax/
{{ ::vm.user }}
<div ng-if="::vm.user.loggedIn"></div>
<div ng-class="::{ loggedIn: vm.user.loggedIn }"></div>
<ul>
<li ng-repeat="user in ::vm.users"></li>
</ul>
感谢投票者.
这篇关于angularjs 1.4中的一种方法绑定的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文