AngularJS


Angularjs-basic-custom-directives All Versions

0.9.0
0.9.1
0.9.2
0.9.3
0.9.4
0.9.5
0.9.6
0.9.7
0.9.9
0.9.10
0.9.11
0.9.12
0.9.13
0.9.14
0.9.15
0.9.16
0.9.17
0.9.18
0.9.19
0.10.0
0.10.1
0.10.2
0.10.3
0.10.4
0.10.5
0.10.6
1.0.0rc1
g3-v1.0.0rc1
g3-v1.0.0-rc2
v1.0.0rc2
v1.0.0rc3
v1.0.0rc4
v1.0.0rc5
v1.0.0rc6
v1.0.0rc7
v1.0.0rc8
v1.0.0rc9
v1.0.0rc10
v1.0.0rc11
v1.0.0rc12
1.0.0
1.0.1
1.0.2
1.1.0
1.0.3
1.1.1
1.0.4
1.1.2
1.0.5
1.1.3
1.0.6
1.1.4
1.0.7
1.1.5
1.2.0rc1
1.0.8
1.2.0-rc.2
1.2.0-rc.3
1.2.0
1.2.1
1.2.2
1.2.3
1.2.4
1.2.5
1.2.6
1.2.7
1.2.8
1.2.9
1.2.10
1.2.11
1.2.12
1.2.13
1.2.14
1.3.0-beta.1
1.3.0-beta.2
1.3.0-beta.3
1.2.15
1.3.0-beta.4
1.2.16
1.3.0-beta.5
1.3.0-beta.6
1.3.0-beta.7
1.3.0-beta.8
1.3.0-beta.9
1.3.0-beta.10
1.2.17
1.3.0-beta.11
1.2.18
1.3.0-beta.12
1.3.0-beta.13
1.2.19
1.3.0-beta.14
1.2.20
1.3.0-beta.15
1.3.0-beta.16
1.2.21
1.3.0-beta.17
1.2.22
1.3.0-beta.18
1.2.23
1.3.0-beta.19
1.3.0-rc.0
1.2.24
1.3.0-rc.1
1.2.25
1.3.0-rc.2
1.3.0-rc.3
1.3.0-rc.4
1.2.26
1.3.0-rc.5
1.3.0
1.3.1
1.3.2
1.3.3
1.2.27
1.3.4
1.3.5
1.3.6
1.3.7
1.2.28
1.3.8
1.4.0-beta.0
1.3.9
1.3.10
1.4.0-beta.1
1.3.11
1.4.0-beta.2
1.3.12
1.4.0-beta.3
1.3.13
1.4.0-beta.4
1.3.14
1.4.0-beta.5
1.3.15
1.4.0-beta.6
1.4.0-rc.0
1.4.0-rc.1
1.4.0-rc.2
1.4.0
1.3.16
1.4.1
1.3.17
1.4.2
1.4.3
1.4.4
1.3.18
1.4.5
1.3.19
1.4.6
1.5.0-beta.0
1.2.29
1.3.20
1.4.7
1.5.0-beta.1
1.5.0-beta.2
1.4.8
1.5.0-rc.0
1.5.0-rc.1
1.4.9
1.5.0-rc.2
1.5.0
1.4.10
1.5.1
1.5.2
1.5.3
1.5.4
1.5.5
1.4.11
1.5.6
1.4.12
1.5.7
1.2.30
1.5.8

Improvements requested:

  • This topic duplicates material from other topics, is deprecated, is obsolete, or is otherwise superfluous. –  Sebastianb Dec 6 at 15:27
    as user blag pointed out, there's another topic about custom directives already: http://stackoverflow.com/documentation/angularjs/965/custom-directives#t=201612060714451825704

This draft deletes the entire topic.

Introduction

Introduction

expand all collapse all

Examples

  • Improvements requested:

    • This was posted as an example, but it does not attempt to illustrate the topic. It should possibly be an edit to the topic, a separate topic, or deleted altogether. –  Blag Dec 6 at 7:18
      I don't know about the use of fiddle in doc... as you don't have the integrated snippet I think it's ok... BTW, I see there is already a [Custom Directive topic](http://stackoverflow.com/documentation/angularjs/965/custom-directives#t=201612060714451825704) post inside please and don't make a new one. As it's full, I suggest you to make some edit to improve the current Doc and not start a new one
      1. Try to cast some upvote on the good content of the other topic. If you think there is enough to make two topic, split them in Basic Custom Directives and Advanced Custom Directives
    0

    Directives are the most important components of AngularJS applications. AngularJS has it's own built-in directives and also lets you to create your own custom directives.

    HTML

    <div ng-app="myApp">
      <div ng-controller="myCtrl">
        <my-directive first-model="result"></my-directive>
        <div>
          {{result}}
        </div>
      </div>
    </div>
    

    JS

    var myApp = angular.module('myApp', [])
    
    .controller("myCtrl", function($scope) {
      $scope.result = "";
    })
    
    .directive('myDirective', function() {
      return {
        restrict: 'E',
        scope: {
          mymodel: '=firstModel'
        },
        template: '<input ng-model="mymodel"/>'
      }
    });
    

    Fiddle : http://jsfiddle.net/6GU6x/94/

Please consider making a request to improve this example.

Syntax

Syntax

Parameters

Parameters

Remarks

Remarks

Still have a question about Angularjs-basic-custom-directives? Ask Question

Topic Outline