私はちょうど Angularjs を理解し始めたところですが、ドキュメントで以下を見てきました。ng-bind-html と ng-model の両方を一緒に使用すると競合すると思いますか?
angular.module('customControl', []).
directive('contenteditable', function() {
return {
restrict: 'A', // only activate on element attribute
require: '?ngModel', // get a hold of NgModelController
link: function(scope, element, attrs, ngModel) {
if(!ngModel) return; // do nothing if no ng-model
// Specify how UI should be updated
ngModel.$render = function() {
element.html(ngModel.$viewValue || '');
};
// Listen for change events to enable binding
element.on('blur keyup change', function() {
scope.$apply(read);
});
read(); // initialize
// Write data to the model
function read() {
var html = element.html();
// When we clear the content editable the browser leaves a <br> behind
// If strip-br attribute is provided then we strip this out
if( attrs.stripBr && html == '<br>' ) {
html = '';
}
ngModel.$setViewValue(html);
}
}
};
});
https://docs.angularjs.org/api/ng/type/ngModel.NgModelControllerから
現在、以下のように ng-bind-html ディレクティブを使用しています (双方向バインディングではありませんが、うまく機能します)。
<div ng-bind-html="person.nameHtml" contenteditable="true"></div>