I have two directives with the same functions as shown below.
angular.module('ui.directives', []) .directive('uiFoo', function() { return { restrict: 'EAC', link: function($scope, element, attrs) { //to do functionality element.append("test content"); } }; }) .directive('uiFoo1', function() { return { restrict: 'EAC', link: function($scope, element, attrs) { //to do functionality element.append("test content"); } }; });
Both of them contain the same thing as here, this adds “test content” as text to this element. Is it likely that you will do these two directives instead. Can I write two names for one directive / I can use the same functionality with code optimization. Here I write the same code without any meaning. Instead of writing the directive twice, is there any way to optimize. I am new to AngularJS, kindly help me. Thanks in advance!
source share