Just starting out with Angular and delving into directives. While working on my directive's link
function, I noticed that when I log my element, it shows up as an array. This raised the question in my mind - why is it an array?
<mouse-enter>HI</mouse-enter>
JS:
angular.module('custom.directive').directive('mouseEnter', function () {
return {
restrict: 'E',
link: function (scope, element) {
console.log(element);// It's logging as an array here!
element[0].onmouseover = function () {
console.log('Mouse Entered!');
};
}
}
});
When could this array potentially have a length greater than 1? The mystery deepens!