我想将图像上传到服务器并将其作为图像放置在我的文本中。
编辑:
<summernote ng-model="answer.value" id="answerValue" config="options" on-image-upload="imageUpload(files)" editable="editable" editor="editor"></summernote>
JS 代码:
$scope.options = {
height: 400
};
$scope.imageUpload = function(files) {
answer.uploadImage(files[0]).then(function(result) {
console.log('image upload\'s editor:', $scope.editor);
console.log('image upload\'s editable:', $scope.editable);
$scope.editor.insertImage($scope.editable, result.data.url);
}, function(result) {
});
};
图书馆:
<script src="bower_components/jquery/dist/jquery.min.js"></script>
<script src="bower_components/bootstrap/dist/js/bootstrap.min.js"></script>
<script src="bower_components/summernote/dist/summernote.min.js"></script>
<script src="bower_components/angular/angular.min.js"></script>
<script src="bower_components/angular-summernote/dist/angular-summernote.min.js"></script>
$scope.editor 和 $scope.editable 已定义,但它说:
$scope.editor.insertImage is not a function
有人知道我做错了什么吗?
最佳答案
更改代码
$scope.editor.insertImage($scope.editable, result.data.url);
至
$scope.editor.summernote('insertImage', result.data.url, 'filename');
它可以在 Summernote 0.7.0 中使用 Angular-summernote 运行
关于javascript - Angularjs Summernote : $scope. editor.insertImage 不是函数,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/34342529/