I have a directive inside it that has a list. This list is populated after the successful response of an ajax call. That's why my directive link function does not find this list as soon as the page loads, only when ajax loads.
How do I apply click events to this list once I have the ajax response?
Directive code:
function localizationFilter(){
var directive = {
restrict: 'E',
replace: true,
scope: true,
templateUrl: 'template.html',
scope: {
controller: '=',
list: '='
},
compile: function(tElement, attr){
return function(scope, elem, attrs) {
var checks = elem.find('li')
console.log(checks) // não encontra nada
}
}
}
return directive
}
Template of the directive:
<ul class="filter-subitens-list">
<li ng-repeat="item in list">
<input type="checkbox" id="{{item + $index}}" value="{{item.name}}">
<label for="{{item.name + $index}}">
{{item.name}} <span>{{item.total}}</span>
</label>
</li>
</ul>