Last active
December 18, 2015 19:39
-
-
Save filipesperandio/5834733 to your computer and use it in GitHub Desktop.
Basic Angular Directive Definition
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var directiveFunction = function() { | |
return function(scope, element, att) { | |
console.log(scope); //scope is the real angular scope related to that DOM element | |
console.log(element); //element is a jquery like object and has a subset of jquery functions -> http://docs.angularjs.org/api/angular.element | |
console.log(att); //att has the attributes you pass on the directive | |
console.log(att.something); // fulano | |
} | |
}; | |
module.directive("something", directiveFunction ); | |
// <div something="fulano"></div> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment