Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Angular.js 1.3 One-time binding in ng-bind

In Angular.js 1.3 I can do a one time binding with:

{{::name}} 

But how may I use this in ng-bind?

ng-bind had some performance improvements in comparison to the {{ syntax.

Is it supported?

like image 864
Boas Enkler Avatar asked Nov 04 '14 12:11

Boas Enkler


People also ask

What is one-time binding in AngularJS?

At a high-level, one-time data binding means that the template is rendered once based on the current $scope and then it never updates.

What is the syntax for a one-time binding?

One-time binding is used for values that won't change after the page is stable. "Stable" generally means that the expression has been assigned a value. Once the value is set, changes to the value in the controller won't change the displayed value until the page is reloaded. The syntax is {{::expression}}.

What is Ng repeat in AngularJS?

AngularJS ng-repeat Directive The ng-repeat directive repeats a set of HTML, a given number of times. The set of HTML will be repeated once per item in a collection. The collection must be an array or an object. Note: Each instance of the repetition is given its own scope, which consist of the current item.

What is difference between ng-model and Ng-bind?

ngModel usually use for input tags for bind a variable that we can change variable from controller and html page but ngBind use for display a variable in html page and we can change variable just from controller and html just show variable.


1 Answers

Yes. This works:

<span ng-bind="::name"></span> 
like image 81
seldary Avatar answered Sep 28 '22 00:09

seldary