Skip to content

Instantly share code, notes, and snippets.

@swallentin
Created February 25, 2016 13:02
Show Gist options
  • Save swallentin/cfa9c423d6b47609142d to your computer and use it in GitHub Desktop.
Save swallentin/cfa9c423d6b47609142d to your computer and use it in GitHub Desktop.
Angular Directive Implementation Comparision
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);
}
}
};
});
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