标签:javascript angularjs twitter-bootstrap codemirror
我的代码如下:
<ul id="myTab" class="nav nav-tabs">
<li class="active"><a href="#user_interface" data-toggle="tab">User Interface</a></li>
<li class=""><a href="#source_code" data-toggle="tab">Source Code</a></li>
</ul>
<div id="myTabContent" class="tab-content">
<div class="tab-pane fade active in" id="user_interface">
<textarea data-ui-tinymce id="tinymce1" tinymce-modal-id="myModalTinyMCE" allow-tinymce-image="true" data-ng-model="from_one.from_one"></textarea>
</div>
<div class="tab-pane fade" id="source_code" >
<div style="border-left:1px solid #DDD; border-right:1px solid #DDD; border-bottom:1px solid #DDD">
<textarea ui-codemirror ui-codemirror-opts="editorOptions" data-ng-model="from_one.from_one">
</textarea>
</div>
</div>
</div>
当我单击第二个选项卡“源代码”时,模型绑定中的内容不会在代码编辑器中显示如下图所示.
只有当我再次点击代码编辑器内容时,才会出现数据:
有谁知道如何解决这个问题?
解决方法:
我见过这个问题,但已经解决了.
您可以在https://github.com/angular-ui/ui-codemirror再次阅读ui-codemirror angular的文档,有一个段落:
” ui-refresh directive
If you apply the refresh directive to element then any change to do
this scope value will result to a refresh of the CodeMirror instance.The ui-refresh directive expects a scope variable that can be any
thing….Now
you can set the isSomething in the controller scope.$scope.isSomething = true; “
因此,当更改选项卡或其他代码自动更新操作时,您需要更改“isSomething”的值.
例如:
// HTML:
<tabset>
<tab select="selectTab()" heading="Tab 1">
<div ui-codemirror ng-model="data" ui-codemirror-opts="editorOptions" ui-refresh='refresh'></div>
</tab>
<tab>.....</tab>
</tabset>
// js控制器:
$scope.refresh = false;
$scope.selectTab = function() {
$scope.refresh = !$scope.refresh;
};
希望能帮助你.
标签:javascript,angularjs,twitter-bootstrap,codemirror 来源: https://codeday.me/bug/20190628/1317933.html
本站声明: 1. iCode9 技术分享网(下文简称本站)提供的所有内容,仅供技术学习、探讨和分享; 2. 关于本站的所有留言、评论、转载及引用,纯属内容发起人的个人观点,与本站观点和立场无关; 3. 关于本站的所有言论和文字,纯属内容发起人的个人观点,与本站观点和立场无关; 4. 本站文章均是网友提供,不完全保证技术分享内容的完整性、准确性、时效性、风险性和版权归属;如您发现该文章侵犯了您的权益,可联系我们第一时间进行删除; 5. 本站为非盈利性的个人网站,所有内容不会用来进行牟利,也不会利用任何形式的广告来间接获益,纯粹是为了广大技术爱好者提供技术内容和技术思想的分享性交流网站。