我有一个名为的指令contenteditable
,其隔离范围为post: "&"
问题:
如何将名为 Post 的隔离范围替换为默认的 contenteditable 指令。
angular.module('t23App').
directive("contenteditable", function() {
return {
restrict: "A",
require: "ngModel",
scope: {
post: "&"
},
link: function(scope, element, attrs, ngModel) {
console.log(contenteditable)
function read() {
ngModel.$setViewValue(element.html());
}
ngModel.$render = function() {
element.html(ngModel.$viewValue || "");
};
element.bind("blur keyup change", function() {
scope.$apply(read);
});
}
};
});
因此:目前看起来像这样
<div contenteditable post="dosomething()"> Click this</div>
最后的 html 将如下所示:
<div contenteditable="dosomething()"> Click this</div>