Skip to content
This repository was archived by the owner on Apr 12, 2024. It is now read-only.

Commit 1b1684c

Browse files
gkalpakmgol
authored andcommitted
docs($compile): fix typos and incorrect example
(cherry picked from commit 1147f0e)
1 parent 726f49d commit 1b1684c

File tree

1 file changed

+33
-32
lines changed

1 file changed

+33
-32
lines changed

src/ng/compile.js

+33-32
Original file line numberDiff line numberDiff line change
@@ -205,7 +205,7 @@
205205
*
206206
* This example show how you might use `$doCheck` to trigger changes in your component's inputs even if the
207207
* 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.)
209209
*
210210
* <example name="doCheckArrayExample" module="do-check-module">
211211
* <file name="index.html">
@@ -528,7 +528,7 @@
528528
* would result in the whole app "stalling" until all templates are loaded asynchronously - even in the
529529
* case when only one deeply nested directive has `templateUrl`.
530530
*
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}.
532532
*
533533
* You can specify `templateUrl` as a string representing the URL or as a function which takes two
534534
* arguments `tElement` and `tAttrs` (described in the `compile` function api below) and returns
@@ -589,7 +589,7 @@
589589
* own templates or compile functions. Compiling these directives results in an infinite loop and
590590
* stack overflow errors.
591591
*
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
593593
* a directive's template instead of relying on automatic template compilation via `template` or
594594
* `templateUrl` declaration or manual compilation inside the compile function.
595595
* </div>
@@ -693,17 +693,17 @@
693693
*
694694
* * `true` - transclude the content (i.e. the child nodes) of the directive's element.
695695
* * `'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`
697697
* property is ignored.
698698
* * **`{...}` (an object hash):** - map elements of the content onto transclusion "slots" in the template.
699699
*
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.
701701
*
702702
* This object is a map where the keys are the name of the slot to fill and the value is an element selector
703703
* used to match the HTML to the slot. The element selector should be in normalized form (e.g. `myElement`)
704704
* and will match the standard element variants (e.g. `my-element`, `my:element`, `data-my-element`, etc).
705705
*
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}.
707707
*
708708
* If the element selector is prefixed with a `?` then that slot is optional.
709709
*
@@ -728,7 +728,7 @@
728728
* </div>
729729
*
730730
* 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
732732
* object that contains the compiled DOM, which is linked to the correct transclusion scope.
733733
*
734734
* When you call a transclusion function you can pass in a **clone attach function**. This function accepts
@@ -813,8 +813,8 @@
813813
* The {@link ng.$compile.directive.Attributes Attributes} object - passed as a parameter in the
814814
* `link()` or `compile()` functions. It has a variety of uses.
815815
*
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
818818
* to the attributes.
819819
*
820820
* * *Directive inter-communication:* All directives share the same instance of the attributes
@@ -855,25 +855,24 @@
855855
<file name="index.html">
856856
<script>
857857
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'.
860860
$compileProvider.directive('compile', function($compile) {
861-
// directive factory creates a link function
861+
// The directive factory creates a link function.
862862
return function(scope, element, attrs) {
863863
scope.$watch(
864864
function(scope) {
865-
// watch the 'compile' expression for changes
865+
// Watch the 'compile' expression for changes.
866866
return scope.$eval(attrs.compile);
867867
},
868868
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.
871871
element.html(value);
872872
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.
877876
$compile(element.contents())(scope);
878877
}
879878
);
@@ -946,35 +945,37 @@
946945
* }
947946
* ```
948947
* * `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.
951950
*
952951
* Calling the linking function returns the element of the template. It is either the original
953952
* element passed in, or the clone of the element if the `cloneAttachFn` is provided.
954953
*
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
956955
* AngularJS automatically.
957956
*
958957
* If you need access to the bound view, there are two ways to do it:
959958
*
960959
* - If you are not asking the linking function to clone the template, create the DOM element(s)
961960
* before you send them to the compiler and keep this reference around.
962961
* ```js
963-
* var element = $compile('<p>{{total}}</p>')(scope);
962+
* var element = angular.element('<p>{{total}}</p>');
963+
* $compile(element)(scope);
964964
* ```
965965
*
966966
* - if on the other hand, you need the element to be cloned, the view reference from the original
967967
* 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:
969970
* ```js
970-
* var templateElement = angular.element('<p>{{total}}</p>'),
971-
* scope = ....;
972-
*
971+
* var templateElement = angular.element('<p>{{total}}</p>');
973972
* 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.
975974
* });
976975
*
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`.
978979
* ```
979980
*
980981
*
@@ -1500,9 +1501,9 @@ function $CompileProvider($provide, $$sanitizeUriProvider) {
15001501
* @description
15011502
* Register a new directive with the compiler.
15021503
*
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.
15061507
* @param {Function|Array} directiveFactory An injectable directive factory function. See the
15071508
* {@link guide/directive directive guide} and the {@link $compile compile API} for more info.
15081509
* @returns {ng.$compileProvider} Self for chaining.

0 commit comments

Comments
 (0)