【发布时间】:2016-09-30 12:25:45
【问题描述】:
根据documentation,您应该这样做:
<div ng-controller="OptCtrl">
<summernote config="options"></summernote>
</div>
var HelloButton = function (context) {
var ui = $.summernote.ui;
// create button
var button = ui.button({
contents: '<i class="fa fa-child"/> Hello',
tooltip: 'hello',
click: function () {
// invoke insertText method with 'hello' on editor module.
context.invoke('editor.insertText', 'hello');
}
});
return button.render(); // return button as jquery object
}
angular.module('summernoteDemo', ['summernote'])
.controller('OptCtrl', function($scope) {
$scope.options = {
toolbar: [
['mybutton', ['hello']]
],
buttons: {
hello: HelloButton
}
};
});
我试过这个例子。它很好地显示了 hello 按钮,但是当我单击它时出现错误:
Uncaught TypeError: Cannot read property 'invoke' of undefined
在这条线上context.invoke('editor.insertText', 'hello');
(上下文未定义..)
你知道如何解决它吗?
我正在使用:
"summernote": "^0.7.3",
"angular-summernote": "^0.7.1"
谢谢
【问题讨论】:
标签: javascript jquery angularjs summernote