This is my Angular code:
angular.module('player', [])
.directive('playButton', function() {
return {
restrict: 'A',
/* I want to get the element parameter bellow as HTMl,
not an object with an element stored within.
I don't want to access the HTML element as element[0]*/
link: function($scope, /* this parameter -> */ element, attr) {
console.log(typeof(element));
// element[0].addEvent('click', function() {
// console.log('Moo!');
// });
}
}
})
What i want to achieve is getting the element parameter within the link method as html, so that i can manipulate it with MooTools. Is there any way to prevent the use of the [0] after the element variable?
This is my Angular code:
angular.module('player', [])
.directive('playButton', function() {
return {
restrict: 'A',
/* I want to get the element parameter bellow as HTMl,
not an object with an element stored within.
I don't want to access the HTML element as element[0]*/
link: function($scope, /* this parameter -> */ element, attr) {
console.log(typeof(element));
// element[0].addEvent('click', function() {
// console.log('Moo!');
// });
}
}
})
What i want to achieve is getting the element parameter within the link method as html, so that i can manipulate it with MooTools. Is there any way to prevent the use of the [0] after the element variable?
Share Improve this question asked Aug 24, 2013 at 23:21 jvakuilerjvakuiler 5281 gold badge6 silver badges17 bronze badges1 Answer
Reset to default 5No. Angular return a jQlite object. So, like jQuery, to select current html element you need to use element[0]
. An alternative would be to assign a variable to element[0]
.
var elm = element[0];
elm.addEvent('click', function() {
console.log('Moo!');
});
发布者:admin,转转请注明出处:http://www.yc00.com/questions/1744909604a4600466.html
评论列表(0条)