angularjs 与 ueditor 使用的时候 setContent 报错

来源:互联网 发布:js请求servlet 编辑:程序博客网 时间:2024/05/18 01:58

在http成功的回调函数里面

var ue = UE.getEditor('answer');


$http.get("question_get", {params: post}).then(function (response) {console.log(response);$scope.list = response.data.result;$("#picture").show();UE.getEditor('answer').setContent($scope.list.answer);});

直接对ueditor赋值,发现有时候程序报错,而且几率很大,经查找,原因为调用setContent的时候ueditor还未成功初始化

UE.getEditor('answer').setContent($scope.list.answer);

这行代码修改为:


ue.addListener("ready", function () {  UE.getEditor('answer').setContent($scope.list.answer);});

测试后,再没有没发现这样的问题

0 0
原创粉丝点击