I am attempting to create a slide toggle effect on the closest .contactDetails
element when clicking on a
. However, my current code is not producing the desired result.
<ul>
<li ng-repeat="detail in details">
<div>
<a show-contact>{{something}}</a>
<div class="contactDetails">
<ul>
<li ng-repeat="another ng-repeat">
<b>{{something}}</b>
</li>
</ul>
</div>
<br>
</div>
</li>
</ul>
app.directive("showContact", function () {
return {
restrict: "A",
link: function (scope, element) {
element.click(function () {
element.find(".contactDetails").slideToggle();
});
}
};
});
It seems that AngularJS might be having difficulty locating the closest .contactDetails
, resulting in the failure of the slideToggle()
function.
I have also attempted using
element.closest(".contactDetails")
, but this did not yield the expected outcome either. Any assistance would be greatly appreciated. Thank you.