admin管理员组

文章数量:1332389

I am making an application with angular js. I am binding content in the page using {{ data.content }} method, this works fine, but while loading the web page browser shows the same code in the page.

see the screenshot I've taken while page loading

click here

is there any way to clear this without using ng-bind method ?

EDIT

I have tried this method

1 -added ng-clock for body

<body ng-app="MyApp"   ng-cloack ng-controller="MyController" >

2 -added css style for ng-clock

  [ng\:cloak], [ng-cloak], [data-ng-cloak], [x-ng-cloak], .ng-cloak, .x-ng-cloak {
  display: none !important;
}

but still the same problem persists.

and I'm using latest version of both chorme and mozilla firefox

I am making an application with angular js. I am binding content in the page using {{ data.content }} method, this works fine, but while loading the web page browser shows the same code in the page.

see the screenshot I've taken while page loading

click here

is there any way to clear this without using ng-bind method ?

EDIT

I have tried this method

1 -added ng-clock for body

<body ng-app="MyApp"   ng-cloack ng-controller="MyController" >

2 -added css style for ng-clock

  [ng\:cloak], [ng-cloak], [data-ng-cloak], [x-ng-cloak], .ng-cloak, .x-ng-cloak {
  display: none !important;
}

but still the same problem persists.

and I'm using latest version of both chorme and mozilla firefox

Share Improve this question edited Jan 28, 2015 at 4:05 droidev asked Jan 28, 2015 at 3:24 droidevdroidev 7,39011 gold badges64 silver badges98 bronze badges 3
  • So it's not that it is flashing the unpiled page then ... It's more the page doesn't work? Any errors in the console? – Matt Tester Commented Jan 28, 2015 at 4:12
  • 2 ng-cloack ? ng-cloak – PSL Commented Jan 28, 2015 at 4:13
  • 1 @PSL oohhh... I'll edit and check – droidev Commented Jan 28, 2015 at 4:16
Add a ment  | 

2 Answers 2

Reset to default 8

I believe the issue is the delay in angular piling the page when it first downloads. Take a look at ngCloak - https://docs.angularjs/api/ng/directive/ngCloak.

The ngCloak directive is used to prevent the Angular html template from being briefly displayed by the browser in its raw (unpiled) form while your application is loading. Use this directive to avoid the undesirable flicker effect caused by the html template display.

So, add this to your CSS file:

[ng\:cloak], [ng-cloak], [data-ng-cloak], [x-ng-cloak], .ng-cloak, .x-ng-cloak {
  display: none !important;
}

And in your html:

<body ng-cloak>

Note, for legacy browser 'support' (e.g. IE7), it would need to be:

<body ng-cloak class="ng-cloak">

Add below code, ngCloak prevent template being displayed while loading.

<style>
[ng\:cloak], [ng-cloak], [data-ng-cloak], [x-ng-cloak], .ng-cloak, .x-ng-cloak {
  display: none !important;
}
</style>

and then call this class in body tag:

<body ng-cloak class="ng-cloak">

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

本文标签: javascriptAngularJS Shows its own tags while page loadsStack Overflow