Last active
August 29, 2015 14:13
-
-
Save kfiil/5ad4041110b324138953 to your computer and use it in GitHub Desktop.
AngularJS kursus, custom directives
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
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