I have the following directive for a drop down menu (http://jsfiddle.net/77f4m6n5/2/):
<a href="#" dropdown>Open
<ul>
<li>Item 1</li>
<li>Item 2</li>
</ul>
</a>
And the directive is the following:
app.directive("dropdown", dropdown);
function dropdown() {
var dropdown = {
link: link,
replace: false,
restrict: "A"
};
return dropdown;
function link(scope, element, attributes) {
element.bind("click", function(event) {
element.children().toggleClass("active");
});
}
}
Can I create such a directive but more in "an angular way"? I think I should have a directive for the link and another for the dropdown, no?