Search in Help for developer site.

Tuesday 3 October 2017

Remove angularjs double curly braces notation while page is loading

How to remove double braces notation while page is loading in AngularJS.

While developing AngularJs application we use curly braces notation for data binding.

When the page is loading, The AngularJS has not initialized that time those "Curly braces are visible in the UI with the our binding expression". So how to fix that?

We use ng-cloak built in directive to remove curly braces.

The ngCloak directive is used to prevent the AngularJS html template from being briefly displayed by the browser in its raw (uncompiled) form while your application is loading. So we use this directive to hide those curly braces notation while application is loading.

ngCloak directive uses

<div id="helloDiv" ng-cloak>{{ 'hello' }}</div>

ng-bind can also be used

Use ng-bind built in directive instead of curly braces notation.
<div id="helloDiv" ng-bind="hello"></div>

Any Question:

I hope this article helps you to resolve the issue regarding angularjs curly braces notation. If you have any question please write your comments in the comments section below.
Thank you.


9 comments:

  1. 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.

    An alternative solution to this problem would be using the ngCloak directive

    ReplyDelete
  2. ngCloak works in cooperation with the following css rule embedded within angular.js and angular.min.js. For CSP mode please add angular-csp.css to your html file

    ReplyDelete
  3. Thanks Omprakash for your feedback

    ReplyDelete
  4. Excellent ! I am truly impressed that there is so much about this subject that has been revealed and you did it so nicely.
    Angularjs developer

    ReplyDelete
  5. It is very excellent blog and useful article thank you for sharing with us , keep posting
    AngularJS Online Course Hyderabad

    ReplyDelete
  6. Hey, such a beautiful writing style, I admire your work and very thankful to you. It is very helpful and valuable , keep posting.
    Hire Angularjs Developer

    ReplyDelete
  7. Reading your blog feels like embarking on a journey; each sentence is a stepping stone leading to new discoveries. Your dedication to delivering engaging content is truly commendable. You make learning a delightful adventure!

    Same Day Delivery Services in Las Vegas

    ReplyDelete