Created
March 31, 2015 06:35
-
-
Save jfreyre/337b64a96b69750bb25b to your computer and use it in GitHub Desktop.
Angular | Same directive name but different implementation
This file contains hidden or 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
<!doctype html> | |
<html lang="en"> | |
<head> | |
<meta charset="UTF-8"> | |
<title>Example - example-example14-production</title> | |
<script src="//ajax.googleapis.com/ajax/libs/angularjs/1.4.0-beta.6/angular.min.js"></script> | |
<script src="script.js"></script> | |
</head> | |
<body ng-app="multipleDirective"> | |
<my-directive></my-directive> | |
<div my-directive></div> | |
<div class="my-directive"></div> | |
</body> | |
</html> |
This file contains hidden or 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
(function(angular) { | |
'use strict'; | |
angular.module('multipleDirective', []) | |
.directive('myDirective', function() { | |
return { | |
restrict: 'E', | |
template: 'Hey! I am a directive restricted to element' | |
}; | |
}) | |
.directive('myDirective', function() { | |
return { | |
restrict: 'A', | |
template: 'Hey! I am a directive restricted to attribute' | |
}; | |
}) | |
.directive('myDirective', function() { | |
return { | |
restrict: 'C', | |
template: 'Hey! I am a directive restricted to class' | |
}; | |
}); | |
})(window.angular); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment