【发布时间】:2015-07-23 18:02:14
【问题描述】:
我有一个模式需要使用 codemirror 显示一些代码,我正在使用 AngularJS 开发应用程序。 html 如下所示:
<div class="modal-body">
<div ui-codemirror="{onLoad:codemirrorLoaded}" ui-codemirror-opts="viewEventEditorOptions" data-ng-model="event.text"></div>
</div>
我遇到的问题是代码只有在我点击后才会显示在 div 中。我尝试使用如下事件刷新编辑器,但它不起作用:
$scope.codemirrorLoaded = function(_editor){
// Events
_editor.on("beforeChange", function(){ _editor.refresh() });
_editor.on("change", function(){ _editor.refresh() });
};
感谢任何帮助。谢谢。
【问题讨论】:
-
我不知道 codemirror 但是否有可能在您的视图被实例化之前调用 onLoad?如果您的 codemirrorLoaded 回调中有断点,它会在第一次点击之前到达吗?
-
它在模态显示之前被调用。当我第一次点击时不会再次被调用。
-
也许尝试从您的 JS 代码中手动触发该事件?
标签: angularjs codemirror