2016-06-01 55 views
0

根據documentation插入自定義按鈕,你應該做這樣的事情:如何角summernote

<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" 

感謝

回答

0

問題通過更新summernote角summernote到的最後一個版本解決。