Unilateral binding in angular 1.4

According to the study of Angular 1.3: one-time bindings ;

Using the new syntax is as simple as running an expression with ::. Therefore, if we apply the one-time expression to our example above, we will change this:

<p>Hello {{name}}!</p> 

For this

 <p>Hello {{::name}}!</p> 

and now this is one way to bind.

But how can we create a binding once when using Angular directives such as ng-class? I tried the following, but that did not work:

 ng-model="::name" ng-class="['label',{'label-danger': 'High' == ::tsk.Priority}]: 
+5
source share
1 answer

Got my answer here 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> 

Thanks downvoters.

+11
source

All Articles