From 63ce1f62657eed15849172161efe012e6500cd9f Mon Sep 17 00:00:00 2001 From: Luc Morin Date: Mon, 8 Apr 2013 20:50:32 -0300 Subject: docs(guide/directives): give more details about directive declaration --- docs/content/guide/directive.ngdoc | 22 ++++++++++++++-------- 1 file changed, 14 insertions(+), 8 deletions(-) (limited to 'docs/content/guide') diff --git a/docs/content/guide/directive.ngdoc b/docs/content/guide/directive.ngdoc index ba87f285..c2d22d3b 100644 --- a/docs/content/guide/directive.ngdoc +++ b/docs/content/guide/directive.ngdoc @@ -250,7 +250,12 @@ In this example we will build a directive that displays the current time. # Writing directives (long version) -An example skeleton of the directive is shown here, for the complete list see below. +There are different ways to declare a directive. The difference resides in the return +value of the factory function. You can either return a Directive Definition Object +(see below) that defines the directive properties, or just the postLink function +of such an object (all other properties will have the default values). + +Here's an example directive declared with a Directive Definition Object:
   var myModule = angular.module(...);
@@ -276,12 +281,11 @@ An example skeleton of the directive is shown here, for the complete list see be
   });
 
-In most cases you will not need such fine control and so the above can be simplified. All of the -different parts of this skeleton are explained in following sections. In this section we are -interested only in some of this skeleton. +In most cases you will not need such fine control and so the above can be simplified. You can still +return a Directive Definition Object, but only setting the 'compile' function property of the Object, +and rely on the default values for other properties. -The first step in simplifying the code is to rely on the default values. Therefore the above can be -simplified as: +Therefore the above can be simplified as:
   var myModule = angular.module(...);
@@ -296,8 +300,10 @@ simplified as:
   });
 
-Most directives concern themselves only with instances, not with template transformations, allowing -further simplification: +Finally, most directives concern themselves only with instances, not with template transformations, allowing +further simplification. + +Here we only define the postLink function:
   var myModule = angular.module(...);
-- 
cgit v1.2.3