UNPKG

knowhow-server

Version:

A personal workflow engine that can manage and use any network connected host

65 lines (64 loc) 4.08 kB
<a href="http://github.com/angular/angular.js/tree/v1.2.9/src/ng/directive/ngCloak.js#L3" class="view-source btn btn-action"><i class="icon-zoom-in"> </i> View source</a><a href="http://github.com/angular/angular.js/edit/master/src/ng/directive/ngCloak.js" class="improve-docs btn btn-primary"><i class="icon-edit"> </i> Improve this doc</a><h1><code ng:non-bindable="">ngCloak</code> <div><span class="hint">directive in module <code ng:non-bindable="">ng</code> </span> </div> </h1> <div><h2 id="description">Description</h2> <div class="description"><div class="ng-directive-page ng-directive-ngcloak-page"><p>The <code>ngCloak</code> directive is used to prevent the Angular html template from being briefly displayed by the browser in its raw (uncompiled) form while your application is loading. Use this directive to avoid the undesirable flicker effect caused by the html template display.</p> <p>The directive can be applied to the <code>&lt;body&gt;</code> element, but the preferred usage is to apply multiple <code>ngCloak</code> directives to small portions of the page to permit progressive rendering of the browser view.</p> <p><code>ngCloak</code> works in cooperation with the following css rule embedded within <code>angular.js</code> and <code>angular.min.js</code>. For CSP mode please add <code>angular-csp.css</code> to your html file (see <a href="api/ng.directive:ngCsp"><code>ngCsp</code></a>).</p> <pre class="prettyprint linenums"> [ng\:cloak], [ng-cloak], [data-ng-cloak], [x-ng-cloak], .ng-cloak, .x-ng-cloak { display: none !important; } </pre> <p>When this css rule is loaded by the browser, all html elements (including their children) that are tagged with the <code>ngCloak</code> directive are hidden. When Angular encounters this directive during the compilation of the template it deletes the <code>ngCloak</code> element attribute, making the compiled element visible.</p> <p>For the best result, the <code>angular.js</code> script must be loaded in the head section of the html document; alternatively, the css rule above must be included in the external stylesheet of the application.</p> <p>Legacy browsers, like IE7, do not provide attribute selector support (added in CSS 2.1) so they cannot match the <code>[ng\:cloak]</code> selector. To work around this limitation, you must add the css class <code>ng-cloak</code> in addition to the <code>ngCloak</code> directive as shown in the example below.</p> </div></div> <h2 id="usage">Usage</h2> <div class="usage">as attribute<pre class="prettyprint linenums">&lt;ANY ng-cloak&gt; ... &lt;/ANY&gt;</pre> as class<pre class="prettyprint linenums">&lt;ANY class="ng-cloak"&gt; ... &lt;/ANY&gt;</pre> </div> <h2 id="example">Example</h2> <div class="example"><div class="ng-directive-page ng-directive-ngcloak-page"><h4 id="example_source">Source</h4> <div source-edit="" source-edit-deps="angular.js" source-edit-html="index.html-73" source-edit-css="" source-edit-js="" source-edit-json="" source-edit-unit="" source-edit-scenario="scenario.js-74" source-edit-protractor=""></div> <div class="tabbable"><div class="tab-pane" title="index.html"> <pre class="prettyprint linenums" ng-set-text="index.html-73" ng-html-wrap=" angular.js"></pre> <script type="text/ng-template" id="index.html-73"> <div id="template1" ng-cloak>{{ 'hello' }}</div> <div id="template2" ng-cloak class="ng-cloak">{{ 'hello IE7' }}</div> </script> </div> <div class="tab-pane" title="ngScenario e2e test"> <pre class="prettyprint linenums" ng-set-text="scenario.js-74"></pre> <script type="text/ng-template" id="scenario.js-74"> it('should remove the template directive and css class', function() { expect(element('.doc-example-live #template1').attr('ng-cloak')). not().toBeDefined(); expect(element('.doc-example-live #template2').attr('ng-cloak')). not().toBeDefined(); }); </script> </div> </div><h4 id="example_demo">Demo</h4> <div class="well doc-example-live animate-container" ng-embed-app="" ng-set-html="index.html-73" ng-eval-javascript=""></div> </div></div> </div>