私はAngularが初めてです。私はディレクティブを学ぼうとしていました。ディレクティブのlink
関数で要素をログに記録し、それが配列であることを確認します。なぜそれは配列ですか?
<mouse-enter>HI</mouse-enter>
JS:
angular.module('custom.directive').directive('mouseEnter', function () {
return {
restrict: 'E',
link: function (scope, element) {
console.log(element);// this line prints an array!
element[0].onmouseover = function () {
console.log('Mouse Entered!');
};
}
}
});
その場合、この配列の長さは 1 より大きくなる可能性があります!!