Skip to content

Instantly share code, notes, and snippets.

@kfiil
Last active August 29, 2015 14:13
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save kfiil/5ad4041110b324138953 to your computer and use it in GitHub Desktop.
Save kfiil/5ad4041110b324138953 to your computer and use it in GitHub Desktop.
AngularJS kursus, custom directives
angular.module('moduleName')
.directive('myDirective', function () {
return {
restrict: 'EA', //E = element, A = attribute, C = class, M = comment
scope: {
//@ reads the attribute string value,
//= provides two-way binding,
//& works with functions
title: '@'
},
template: '<div>{{ myVal }}</div>',
templateUrl: 'mytemplate.html',
transclude: true, //Wrap the contents of the directive's element (if transclude is true).
controller: controller,
link: function ($scope, element, attrs) { }//DOM manipulation
}
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment