Skip to content

Instantly share code, notes, and snippets.

@filipesperandio
Last active December 18, 2015 19:39
Show Gist options
  • Save filipesperandio/5834733 to your computer and use it in GitHub Desktop.
Save filipesperandio/5834733 to your computer and use it in GitHub Desktop.
Basic Angular Directive Definition
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