@@ -813,3 +813,61 @@ angularDirective("ng:style", function(expression, element){
813
813
} ;
814
814
} ) ;
815
815
816
+
817
+ /**
818
+ * @ngdoc directive
819
+ * @name angular.directive.ng:cloak
820
+ *
821
+ * @description
822
+ * The `ng:cloak` directive is used to prevent the Angular html template from being briefly
823
+ * displayed by the browser in its raw (uncompiled) form while your application is loading. Use this
824
+ * directive to avoid the undesirable flicker effect caused by the html template display.
825
+ *
826
+ * The directive can be applied to the `<body>` element, but typically a fine-grained application is
827
+ * prefered in order to benefit from progressive rendering of the browser view.
828
+ *
829
+ * `ng:cloak` works in cooperation with a css rule that is embedded within `angular.js` and
830
+ * `angular.min.js` files. Following is the css rule:
831
+ *
832
+ * <pre>
833
+ * [ng\:cloak], .ng-cloak {
834
+ * display: none;
835
+ * }
836
+ * </pre>
837
+ *
838
+ * When this css rule is loaded by the browser, all html elements (including their children) that
839
+ * are tagged with the `ng:cloak` directive are hidden. When Angular comes across this directive
840
+ * during the compilation of the template it deletes the `ng:cloak` element attribute, which
841
+ * makes the compiled element visible.
842
+ *
843
+ * For the best result, `angular.js` script must be loaded in the head section of the html file;
844
+ * alternatively, the css rule (above) must be included in the external stylesheet of the
845
+ * application.
846
+ *
847
+ * Legacy browsers, like IE7, do not provide attribute selector support (added in CSS 2.1) so they
848
+ * cannot match the `[ng\:cloak]` selector. To work around this limitation, you must add the css
849
+ * class `ng-cloak` in addition to `ng:cloak` directive as shown in the example below.
850
+ *
851
+ * @element ANY
852
+ *
853
+ * @example
854
+ <doc:example>
855
+ <doc:source>
856
+ <div id="template1" ng:cloak>{{ 'hello' }}</div>
857
+ <div id="template2" ng:cloak class="ng-cloak">{{ 'hello IE7' }}</div>
858
+ </doc:source>
859
+ <doc:scenario>
860
+ it('should remove the template directive and css class', function() {
861
+ expect(element('.doc-example-live #template1').attr('ng:cloak')).
862
+ not().toBeDefined();
863
+ expect(element('.doc-example-live #template2').attr('ng:cloak')).
864
+ not().toBeDefined();
865
+ });
866
+ </doc:scenario>
867
+ </doc:example>
868
+ *
869
+ */
870
+ angularDirective ( "ng:cloak" , function ( expression , element ) {
871
+ element . removeAttr ( 'ng:cloak' ) ;
872
+ element . removeClass ( 'ng-cloak' ) ;
873
+ } ) ;
0 commit comments