Created
February 25, 2016 13:02
-
-
Save swallentin/cfa9c423d6b47609142d to your computer and use it in GitHub Desktop.
Angular Directive Implementation Comparision
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
| angular.module('eva2-angular').directive('myDirective', function ($state) { | |
| 'use strict'; | |
| return { | |
| restrict: 'A', | |
| link: function (scope, el) { | |
| if($state.current.name !== '') { | |
| angular.element(el).addClass($state.current.name); | |
| } | |
| } | |
| }; | |
| }); |
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
| angular | |
| .module('eva2-angular') | |
| .directive('myDirective', myDirective); | |
| myDirective.$inject = ['$state']; | |
| function myDirective($state) { | |
| var directive = { | |
| controller: Controller, | |
| restrict: 'A', | |
| link: function (scope, el) { | |
| if($state.current.name !== '') { | |
| angular.element(el).addClass($state.current.name); | |
| } | |
| }; | |
| return directive; | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment