現在、Angular ディレクティブで wysihtml5 を使用しようとしていますが、変更イベントを正しく発生させることができないようです。
以下は、私がセットアップしたディレクティブです。
app.directive('wysiwyg', ['$parse', function() {
return {
restrict: "A",
require: "?ngModel",
link: function(scope, element, attrs, ctrl) {
var change = function() {
scope.$apply(function(){
ctrl.$setViewValue($(element).val());
});
};
$(element).wysihtml5({
"font-styles": true, //Font styling, e.g. h1, h2, etc. Default true
"emphasis": true, //Italics, bold, etc. Default true
"lists": true, //(Un)ordered lists, e.g. Bullets, Numbers. Default true
"html": false, //Button which allows you to edit the generated HTML. Default false
"link": true, //Button to insert a link. Default true
"image": true, //Button to insert an image. Default true,
"color": false, //Button to change color of font
"events": {
"change": function() {
window.console.log("changed");
change();
},
"newword:composer": function() {
change();
},
"paste": function() {
change();
}
}
});
}
};
}]);
wysihtml5 のドキュメントによると、これは change 要素をリッスンする方法です。ただし、現在、エディターに変更が加えられるたびにではなく、ブラーが発生したときにのみ発生します。私が探しているべき別のイベントはありますか、それとも Angular ディレクティブを使ってこれを別の方法で行うべきですか?