From 6a98c52c847ecc620118f3ccfdd66c3956c0fb01 Mon Sep 17 00:00:00 2001 From: Misko Hevery Date: Wed, 7 Mar 2012 22:47:01 -0800 Subject: chore(compiler): change default restriction to attribute only for directives --- ...ular.module.ng.$compileProvider.directive.ngdoc | 111 +++++++++++---------- 1 file changed, 56 insertions(+), 55 deletions(-) (limited to 'docs/content/api') diff --git a/docs/content/api/angular.module.ng.$compileProvider.directive.ngdoc b/docs/content/api/angular.module.ng.$compileProvider.directive.ngdoc index 40f272c0..356414fb 100644 --- a/docs/content/api/angular.module.ng.$compileProvider.directive.ngdoc +++ b/docs/content/api/angular.module.ng.$compileProvider.directive.ngdoc @@ -17,13 +17,14 @@ list of some of the possible directive names: `ng:bind`, `ng-bind`, `ng_bind`, ` `data-ng-bind`. The directives can be placed in element names, attributes, class names, as well as comments. Here -are some equivalent examples of invoking `ngBind`. +are some equivalent examples of invoking `myDir`. (However, most directives are restricted to +attribute only.)
- - -Directives can be invoked in many different ways, but are equivalent in the end result as shown in @@ -37,13 +38,12 @@ the following example. }- + + + +
@@ -570,7 +569,9 @@ This will not render properly, unless we do some scope magic. The first issue we have to solve is that the dialog box template expect `title` to be defined, but the place of instantiation would like to bind to `username`. Furthermore the buttons expect `onOk` as well as `onCancel` functions to be present in the scope. This limits the usefulness of the -widget. To solve the mapping issue we use the `locals` to create local variables which the template expects as follows +widget. To solve the mapping issue we use the `locals` to create local variables which the +template expects as follows +locals: { title: 'bind', // set up title to accept data-binding @@ -606,8 +607,7 @@ Therefore the final directive definition looks something like this:transclude: true, -scope: 'isolate', -locals: { +scope: { title: 'bind', // set up title to accept data-binding onOk: 'exp', // create a delegate onOk function onCancel: 'exp', // create a delegate onCancel function @@ -615,7 +615,7 @@ locals: { }-# Creating Widgets +# Creating Components It is often desirable to replace a single directive with a more complex DOM structure. This allows the directives to become a short hand for reusable components from which applications @@ -635,6 +635,7 @@ Following is an example of building a reusable widget. angular.module('zippyModule', []) .directive('zippy', function(){ return { + restrict: 'C', // This HTML will replace the zippy directive. replace: true, transclude: true, -- cgit v1.2.3