@@ -303,6 +303,7 @@ The `restrict` option is typically set to:
303303* `'A'` - only matches attribute name
304304* `'E'` - only matches element name
305305* `'C'` - only matches class name
306+ * `'M'` - only matches comment
306307
307308These restrictions can all be combined as needed:
308309
@@ -646,6 +647,7 @@ To do this, we need to use the `transclude` option.
646647 return {
647648 restrict: 'E',
648649 transclude: true,
650+ scope: {},
649651 templateUrl: 'my-dialog.html'
650652 };
651653 });
@@ -656,8 +658,7 @@ To do this, we need to use the `transclude` option.
656658 </div>
657659 </file>
658660 <file name="my-dialog.html">
659- <div class="alert" ng-transclude>
660- </div>
661+ <div class="alert" ng-transclude></div>
661662 </file>
662663</example>
663664
@@ -679,7 +680,7 @@ that redefines `name` as `Jeff`. What do you think the `{{name}}` binding will r
679680 transclude: true,
680681 scope: {},
681682 templateUrl: 'my-dialog.html',
682- link: function (scope, element ) {
683+ link: function (scope) {
683684 scope.name = 'Jeff';
684685 }
685686 };
@@ -691,8 +692,7 @@ that redefines `name` as `Jeff`. What do you think the `{{name}}` binding will r
691692 </div>
692693 </file>
693694 <file name="my-dialog.html">
694- <div class="alert" ng-transclude>
695- </div>
695+ <div class="alert" ng-transclude></div>
696696 </file>
697697</example>
698698
@@ -703,7 +703,7 @@ The `transclude` option changes the way scopes are nested. It makes it so that t
703703transcluded directive have whatever scope is outside the directive, rather than whatever scope is on
704704the inside. In doing so, it gives the contents access to the outside scope.
705705
706- Note that if the directive did not create its own scope, then `scope` in `scope.name = 'Jeff'; ` would
706+ Note that if the directive did not create its own scope, then `scope` in `scope.name = 'Jeff'` would
707707reference the outside scope and we would see `Jeff` in the output.
708708
709709This behavior makes sense for a directive that wraps some content, because otherwise you'd have to
@@ -776,9 +776,9 @@ function.
776776
777777Often it's desirable to pass data from the isolate scope via an expression to the
778778parent scope, this can be done by passing a map of local variable names and values into the expression
779- wrapper fn . For example, the hideDialog function takes a message to display when the dialog is hidden.
780- This is specified in the directive by calling `close({message: 'closing for now'})`. Then the local
781- variable `message` will be available within the `on-close` expression.
779+ wrapper function . For example, the ` hideDialog` function takes a message to display when the dialog
780+ is hidden. This is specified in the directive by calling `close({message: 'closing for now'})`.
781+ Then the local variable `message` will be available within the `on-close` expression.
782782
783783<div class="alert alert-success">
784784**Best Practice:** use `&attr` in the `scope` option when you want your directive
@@ -837,7 +837,7 @@ element?
837837 }]);
838838 </file>
839839 <file name="index.html">
840- <span my-draggable>Drag ME </span>
840+ <span my-draggable>Drag Me </span>
841841 </file>
842842</example>
843843
@@ -882,7 +882,7 @@ to which tab is active.
882882 })
883883 .directive('myPane', function() {
884884 return {
885- require: '^myTabs',
885+ require: '^^ myTabs',
886886 restrict: 'E',
887887 transclude: true,
888888 scope: {
@@ -898,11 +898,9 @@ to which tab is active.
898898 <file name="index.html">
899899 <my-tabs>
900900 <my-pane title="Hello">
901- <h4>Hello</h4>
902901 <p>Lorem ipsum dolor sit amet</p>
903902 </my-pane>
904903 <my-pane title="World">
905- <h4>World</h4>
906904 <em>Mauris elementum elementum enim at suscipit.</em>
907905 <p><a href ng-click="i = i + 1">counter: {{i || 0}}</a></p>
908906 </my-pane>
@@ -919,22 +917,25 @@ to which tab is active.
919917 </div>
920918 </file>
921919 <file name="my-pane.html">
922- <div class="tab-pane" ng-show="selected" ng-transclude>
920+ <div class="tab-pane" ng-show="selected">
921+ <h4>{{title}}</h4>
922+ <div ng-transclude></div>
923923 </div>
924924 </file>
925925</example>
926926
927- The `myPane` directive has a `require` option with value `^myTabs`. When a directive uses this
928- option, `$compile` will throw an error unless the specified controller is found. The `^` prefix
929- means that this directive searches for the controller on its parents (without the `^` prefix, the
930- directive would look for the controller on just its own element).
927+ The `myPane` directive has a `require` option with value `^^myTabs`. When a directive uses this
928+ option, `$compile` will throw an error unless the specified controller is found. The `^^` prefix
929+ means that this directive searches for the controller on its parents. (A `^` prefix would make the
930+ directive look for the controller on its own element or its parents; without any prefix, the
931+ directive would look on its own element only.)
931932
932933So where does this `myTabs` controller come from? Directives can specify controllers using
933934the unsurprisingly named `controller` option. As you can see, the `myTabs` directive uses this
934935option. Just like `ngController`, this option attaches a controller to the template of the directive.
935936
936- If it is necessary to reference the controller or any functions bound to the controller's scope in
937- the template, you can use the option `controllerAs` to specify the name of the controller as an alias.
937+ If it is necessary to reference the controller or any functions bound to the controller from the
938+ template, you can use the option `controllerAs` to specify the name of the controller as an alias.
938939The directive needs to define a scope for this configuration to be used. This is particularly useful
939940in the case when the directive is used as a component.
940941
@@ -949,7 +950,7 @@ The corresponding parameter being sent to the `link` function will also be an ar
949950angular.module('docsTabsExample', [])
950951 .directive('myPane', function() {
951952 return {
952- require: ['^myTabs', '^ ngModel'],
953+ require: ['^^ myTabs', 'ngModel'],
953954 restrict: 'E',
954955 transclude: true,
955956 scope: {
@@ -985,4 +986,3 @@ available in the {@link guide/compiler compiler guide}.
985986
986987The {@link ng.$compile `$compile` API} page has a comprehensive list of directive options for
987988reference.
988-
0 commit comments