如何根據角度js指令獲取綁定的值restrict: 'A'
?angularjs指令 - 獲取元素綁定的文本內容
<span directiverestrict> {{binding}} </span>
我試圖使用elem[0].innerText
但它返回結合
.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}}'
}
};
});
請添加代碼 –