Angularjs directive - get text content of bound element
How do you get the binding value based on the angular js directive restrict: 'A'
?
<span directiverestrict> {{binding}} </span>
I tried using elem[0].innerText
but it will return the exact binding '{{binding}}'
, not the binding value
.directive('directiverestrict',function() {
return {
restrict:'A',
link: function(scope, elem, attr) {
// I want to get the value of the binding enclosed in the elements directive without ngModels
console.log(elem[0].textContent) //----> returns '{{binding}}'
}
};
});
+3
source to share
3 answers