Within the directory labeled directives
, I have created two files: directives.js
and color.js
I have imported directives
into app.js
Contents of directives.js:
import angular from 'angular';
import ColorDirective from './color';
const moduleName = 'app.directives';
angular.module(moduleName, [])
.directive('color', ColorDirective);
export default moduleName;
Contents of color.js:
import angular from 'angular';
let ColorDirective = function () {
return {
link: function (scope, element) {
console.log('ColorDirective');
}
}
}
export default ColorDirective;
In one component, I have added color
as an attribute to an element
However, it does not seem to be working. There seems to be an issue with the inner link loop. What could be coded incorrectly? How can I effectively use directives in Angular 1.5 & es2016?