3

How to avoid {{ }} codes from showing when the page is just starting up or loading AngularJS resources?

In my case, the {{ c }} is showing inside my dropdown which is really weird for my users.

I can't use ng-bind in my case because I am showing a variable from a ng-repeat inside the option html tags.

Here is the code,

<select ng-model="invoice.inCurrency">
    <option ng-repeat="c in invoice.currencies">{{ c }}</option>
</select>
John Slegers
  • 45,213
  • 22
  • 199
  • 169
Mark Vizcarra
  • 1,165
  • 1
  • 11
  • 15

2 Answers2

8

Put ng-cloak at your controller definition (or wherever you don't want to see the template rendering... specs recommend placing it in small portions of the page):

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

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

tymeJV
  • 103,943
  • 14
  • 161
  • 157
1

You can also try to work with ng-bind instead of {{}} in your view. It is always possible, even in your code :

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

Please refer to this topic to see the advantages of ng-bind

Community
  • 1
  • 1
bviale
  • 5,245
  • 3
  • 28
  • 48