1

I have found the below definition about the difference

Typically, you don't use ngBind directly, but instead you use the double curly markup like {{ expression }} which is similar but less verbose.

It is preferable to use ngBind instead of {{ expression }} if a template is momentarily displayed by the browser in its raw state before AngularJS compiles it. Since ngBind is an element attribute, it makes the bindings invisible to the user while the page is loading.

but i didn't get this properly.

Can anyone explain in simple language with Example?

Thanks

Community
  • 1
  • 1
Tejinder Singh
  • 1,070
  • 2
  • 8
  • 24

1 Answers1

1

ngBind is an attribute. Until your JS files are being loaded and interpreted, that attribute will not be "taken" into consideration, so no HTML artifacts will be displayed.

{{ expression }} instead, is immediately shown as inner HTML on page load, which creates annoying flickers. HTML inner content is briefly displayed in its uncompiled state while your application is loading (all your JS files that get loaded and interpreted). ngCloak is recommended to be used with it.

Nicolae Olariu
  • 2,487
  • 2
  • 18
  • 30
  • http://stackoverflow.com/questions/25741586/difference-between-ng-bind-and-interpolation-in-angular – Nicolae Olariu Apr 03 '17 at 18:55
  • also, `ngBind` is recommended to be used when you have syntax conflicts with other languages – Nicolae Olariu Apr 03 '17 at 18:56
  • Perhaps elaborate as to _why_ [`ngCloak`](http://docs.angularjs.org/api/ng.directive%3angCloak) is recommended and _what it does_ for the OP, or at least give a reference to the [documentation](http://docs.angularjs.org/api/ng.directive%3angCloak) for it – cnorthfield Apr 03 '17 at 19:16
  • Good point @cnorthfield! Was written in hurry. Thanks! – Nicolae Olariu Apr 03 '17 at 19:23