AngularJS codes: {{}} show for split second

How to avoid codes {{ }}

from showing when the page is just starting or AngularJS resources are loading?

In my case, it {{ c }}

appears inside my dropdown, which is really strange for my users.

I cannot use ng-bind

in my case, because I am showing a variable from ng-repeat

inside option

html tags .

Here is the code,

<select ng-model="invoice.inCurrency">
    <option ng-repeat="c in invoice.currencies">{{ c }}</option>
</select>

      

+3


source to share


2 answers


Place ng-cloak

in your controller definition (or wherever you don't want to see the template rendered ... specs recommend putting it in small sections of the page):

<div ng-controller="MyCtrl" ng-cloak>

      



https://docs.angularjs.org/api/ng/directive/ngCloak

+8


source


You can also try working with ng-bind

instead {{}}

in your view. This is always possible even in your code:

<select ng-model="invoice.inCurrency">
    <option ng-repeat="c in invoice.currencies" ng-bind="c"></option>
</select>

      



Refer to this section to see the benefitsng-bind

+1


source







All Articles