I am encountering a problem while using an angular directive and attempting to utilize the jQlite .find() method:
DIRECTIVE
function cardsList () {
return {
restrict: 'A',
controller: 'CardsController',
templateUrl: 'app/directives/cards-list/cards-list.html',
link: function ($scope, $element, attr, CardsController) {
var cardLink = $element.find('a');
console.log(cardLink);
});
}
}
}
contextCards.directive('cardsList', cardsList);
An empty []
is being displayed on the console.
TEMPLATE
<li data-ng-repeat="card in cards" class="cards--item">
<a class="cards--link" data-ng-href="#/{{ card.slug }}">{{ card.title }}</a>
</li>
VIEW
<ul class="col-xs-12 cards--list" cards-list></ul>
I am attempting to access the <a>
elements. As per the documentation, .find()
only functions with tag names, which aligns with my current goal.
EDIT: My objective is to assign a class to the <a></a>
if it represents a selected card (such as .current-card
)