Answer the question
In order to leave comments, you need to log in
How to access child elements in a directive?
Hello.
Actually a question: "How to get access to child elements in the directive?".
What is :
<div class="list" my-directive>
<div class="item"></div>
<div class="item"></div>
<div class="item"></div>
</div>
angular.module('MyModule').directive('myDirective', function(){
return {
restrict : 'A',
scope : {}, // В рабочей версии нужны будут параметры
link : function(scope, el){
console.dir(el.children()); //Возвращает div.directive-div из template
},
compile : function(){
return {
pre : function preLink(scope, el){
console.dir(el.children()); // Возвращает div.directive-div
}
};
},
template : '<div class="directive-div"></div>'
};
});
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question