|
205 | 205 | * |
206 | 206 | * This example show how you might use `$doCheck` to trigger changes in your component's inputs even if the |
207 | 207 | * actual identity of the component doesn't change. (Be aware that cloning and deep equality checks on large |
208 | | - * arrays or objects can have a negative impact on your application performance) |
| 208 | + * arrays or objects can have a negative impact on your application performance.) |
209 | 209 | * |
210 | 210 | * <example name="doCheckArrayExample" module="do-check-module"> |
211 | 211 | * <file name="index.html"> |
|
528 | 528 | * would result in the whole app "stalling" until all templates are loaded asynchronously - even in the |
529 | 529 | * case when only one deeply nested directive has `templateUrl`. |
530 | 530 | * |
531 | | - * Template loading is asynchronous even if the template has been preloaded into the {@link $templateCache} |
| 531 | + * Template loading is asynchronous even if the template has been preloaded into the {@link $templateCache}. |
532 | 532 | * |
533 | 533 | * You can specify `templateUrl` as a string representing the URL or as a function which takes two |
534 | 534 | * arguments `tElement` and `tAttrs` (described in the `compile` function api below) and returns |
|
589 | 589 | * own templates or compile functions. Compiling these directives results in an infinite loop and |
590 | 590 | * stack overflow errors. |
591 | 591 | * |
592 | | - * This can be avoided by manually using $compile in the postLink function to imperatively compile |
| 592 | + * This can be avoided by manually using `$compile` in the postLink function to imperatively compile |
593 | 593 | * a directive's template instead of relying on automatic template compilation via `template` or |
594 | 594 | * `templateUrl` declaration or manual compilation inside the compile function. |
595 | 595 | * </div> |
|
693 | 693 | * |
694 | 694 | * * `true` - transclude the content (i.e. the child nodes) of the directive's element. |
695 | 695 | * * `'element'` - transclude the whole of the directive's element including any directives on this |
696 | | - * element that defined at a lower priority than this directive. When used, the `template` |
| 696 | + * element that are defined at a lower priority than this directive. When used, the `template` |
697 | 697 | * property is ignored. |
698 | 698 | * * **`{...}` (an object hash):** - map elements of the content onto transclusion "slots" in the template. |
699 | 699 | * |
700 | | - * **Mult-slot transclusion** is declared by providing an object for the `transclude` property. |
| 700 | + * **Multi-slot transclusion** is declared by providing an object for the `transclude` property. |
701 | 701 | * |
702 | 702 | * This object is a map where the keys are the name of the slot to fill and the value is an element selector |
703 | 703 | * used to match the HTML to the slot. The element selector should be in normalized form (e.g. `myElement`) |
704 | 704 | * and will match the standard element variants (e.g. `my-element`, `my:element`, `data-my-element`, etc). |
705 | 705 | * |
706 | | - * For further information check out the guide on {@link guide/directive#matching-directives Matching Directives} |
| 706 | + * For further information check out the guide on {@link guide/directive#matching-directives Matching Directives}. |
707 | 707 | * |
708 | 708 | * If the element selector is prefixed with a `?` then that slot is optional. |
709 | 709 | * |
|
728 | 728 | * </div> |
729 | 729 | * |
730 | 730 | * If you want to manually control the insertion and removal of the transcluded content in your directive |
731 | | - * then you must use this transclude function. When you call a transclude function it returns a a jqLite/JQuery |
| 731 | + * then you must use this transclude function. When you call a transclude function it returns a jqLite/JQuery |
732 | 732 | * object that contains the compiled DOM, which is linked to the correct transclusion scope. |
733 | 733 | * |
734 | 734 | * When you call a transclusion function you can pass in a **clone attach function**. This function accepts |
|
813 | 813 | * The {@link ng.$compile.directive.Attributes Attributes} object - passed as a parameter in the |
814 | 814 | * `link()` or `compile()` functions. It has a variety of uses. |
815 | 815 | * |
816 | | - * * *Accessing normalized attribute names:* Directives like 'ngBind' can be expressed in many ways: |
817 | | - * 'ng:bind', `data-ng-bind`, or 'x-ng-bind'. The attributes object allows for normalized access |
| 816 | + * * *Accessing normalized attribute names:* Directives like `ngBind` can be expressed in many ways: |
| 817 | + * `ng:bind`, `data-ng-bind`, or `x-ng-bind`. The attributes object allows for normalized access |
818 | 818 | * to the attributes. |
819 | 819 | * |
820 | 820 | * * *Directive inter-communication:* All directives share the same instance of the attributes |
|
855 | 855 | <file name="index.html"> |
856 | 856 | <script> |
857 | 857 | angular.module('compileExample', [], function($compileProvider) { |
858 | | - // configure new 'compile' directive by passing a directive |
859 | | - // factory function. The factory function injects the '$compile' |
| 858 | + // Configure new 'compile' directive by passing a directive |
| 859 | + // factory function. The factory function injects '$compile'. |
860 | 860 | $compileProvider.directive('compile', function($compile) { |
861 | | - // directive factory creates a link function |
| 861 | + // The directive factory creates a link function. |
862 | 862 | return function(scope, element, attrs) { |
863 | 863 | scope.$watch( |
864 | 864 | function(scope) { |
865 | | - // watch the 'compile' expression for changes |
| 865 | + // Watch the 'compile' expression for changes. |
866 | 866 | return scope.$eval(attrs.compile); |
867 | 867 | }, |
868 | 868 | function(value) { |
869 | | - // when the 'compile' expression changes |
870 | | - // assign it into the current DOM |
| 869 | + // When the 'compile' expression changes |
| 870 | + // assign it into the current DOM. |
871 | 871 | element.html(value); |
872 | 872 |
|
873 | | - // compile the new DOM and link it to the current |
874 | | - // scope. |
875 | | - // NOTE: we only compile .childNodes so that |
876 | | - // we don't get into infinite loop compiling ourselves |
| 873 | + // Compile the new DOM and link it to the current scope. |
| 874 | + // NOTE: we only compile '.childNodes' so that we |
| 875 | + // don't get into an infinite loop compiling ourselves. |
877 | 876 | $compile(element.contents())(scope); |
878 | 877 | } |
879 | 878 | ); |
|
946 | 945 | * } |
947 | 946 | * ``` |
948 | 947 | * * `futureParentElement` - defines the parent to which the `cloneAttachFn` will add |
949 | | - * the cloned elements; only needed for transcludes that are allowed to contain non html |
950 | | - * elements (e.g. SVG elements). See also the directive.controller property. |
| 948 | + * the cloned elements; only needed for transcludes that are allowed to contain non HTML |
| 949 | + * elements (e.g. SVG elements). See also the `directive.controller` property. |
951 | 950 | * |
952 | 951 | * Calling the linking function returns the element of the template. It is either the original |
953 | 952 | * element passed in, or the clone of the element if the `cloneAttachFn` is provided. |
954 | 953 | * |
955 | | - * After linking the view is not updated until after a call to $digest which typically is done by |
| 954 | + * After linking the view is not updated until after a call to `$digest`, which typically is done by |
956 | 955 | * AngularJS automatically. |
957 | 956 | * |
958 | 957 | * If you need access to the bound view, there are two ways to do it: |
959 | 958 | * |
960 | 959 | * - If you are not asking the linking function to clone the template, create the DOM element(s) |
961 | 960 | * before you send them to the compiler and keep this reference around. |
962 | 961 | * ```js |
963 | | - * var element = $compile('<p>{{total}}</p>')(scope); |
| 962 | + * var element = angular.element('<p>{{total}}</p>'); |
| 963 | + * $compile(element)(scope); |
964 | 964 | * ``` |
965 | 965 | * |
966 | 966 | * - if on the other hand, you need the element to be cloned, the view reference from the original |
967 | 967 | * example would not point to the clone, but rather to the original template that was cloned. In |
968 | | - * this case, you can access the clone via the cloneAttachFn: |
| 968 | + * this case, you can access the clone either via the `cloneAttachFn` or the value returned by the |
| 969 | + * linking function: |
969 | 970 | * ```js |
970 | | - * var templateElement = angular.element('<p>{{total}}</p>'), |
971 | | - * scope = ....; |
972 | | - * |
| 971 | + * var templateElement = angular.element('<p>{{total}}</p>'); |
973 | 972 | * var clonedElement = $compile(templateElement)(scope, function(clonedElement, scope) { |
974 | | - * //attach the clone to DOM document at the right place |
| 973 | + * // Attach the clone to DOM document at the right place. |
975 | 974 | * }); |
976 | 975 | * |
977 | | - * //now we have reference to the cloned DOM via `clonedElement` |
| 976 | + * // Now we have reference to the cloned DOM via `clonedElement`. |
| 977 | + * // NOTE: The `clonedElement` returned by the linking function is the same as the |
| 978 | + * // `clonedElement` passed to `cloneAttachFn`. |
978 | 979 | * ``` |
979 | 980 | * |
980 | 981 | * |
@@ -1500,9 +1501,9 @@ function $CompileProvider($provide, $$sanitizeUriProvider) { |
1500 | 1501 | * @description |
1501 | 1502 | * Register a new directive with the compiler. |
1502 | 1503 | * |
1503 | | - * @param {string|Object} name Name of the directive in camel-case (i.e. <code>ngBind</code> which |
1504 | | - * will match as <code>ng-bind</code>), or an object map of directives where the keys are the |
1505 | | - * names and the values are the factories. |
| 1504 | + * @param {string|Object} name Name of the directive in camel-case (i.e. `ngBind` which will match |
| 1505 | + * as `ng-bind`), or an object map of directives where the keys are the names and the values |
| 1506 | + * are the factories. |
1506 | 1507 | * @param {Function|Array} directiveFactory An injectable directive factory function. See the |
1507 | 1508 | * {@link guide/directive directive guide} and the {@link $compile compile API} for more info. |
1508 | 1509 | * @returns {ng.$compileProvider} Self for chaining. |
|
0 commit comments