check out this plunker link.
HTML:
<body ng-app="app">
<h1>selectable</h1>
<selectable text="link1" status="true"></selectable>
<selectable text="link2" status="false"></selectable>
<p>
link1 is <!--status of link1, true or false-->
</p>
<p>
link2 is <!--status of link2, true or false-->
</p>
</body>
JS:
angular.module("app", [])
.directive("selectable", function(){
return {
restrict: "AE",
replace: true,
scope: {
status: "=",
text: "@"
},
link: function(scope, ele, attr){
ele.on("click", function(){
scope.status = !scope.status;
scope.$apply();
});
},
templateUrl: "./tmpl.html"
}
})
template:
<span class='myLink' ng-class='{"active": status, "": !status}'>
{{text}}
{{status}}
</span>
Is there a way to retrieve the current status of both link1 and link2 and display them?
Appreciate any help!