javascript - Codemirror's Onload Function -


trying instance of codemirror using angularjs's tabs.

<p ng-bind-html="tab.content | unsafe"></p> insert textarea:

<tabset class="tab-container">     <tab id = "tabcontent" ng-repeat="tab in tabs" active="tab.active">        <script>        </script>       <tab-heading>       <span>{{tab.title}}</span>       <i class="glyphicon glyphicon-remove" ng-click="removetab($event, $index)"></i> <!-- tab close button -->     </tab-heading>     <p ng-bind-html="tab.content | unsafe"></p>   </tab>   <button class="btn btn-default" ng-click="addtab()"></button> </tabset> 

when add tab.content in, first add html tags around text in order insert textarea:

var formattext = function(text){         return "<textarea ui-codemirror='cmoption' ng-model='cmmodel'>" + text + "</textarea>";      } 

the ui-codemirror = 'cmoption' triggers this:

$scope.cmoption = {     linenumbers: true,     indentwithtabs: true,     onload : function(_cm){         console.log("loaded");         $scope.modechanged = function(){             console.log("loaded");              _cm.setoption("mode", $scope.mode.tolowercase());         };     } }; 

when add breakpoint @ $scope.cmoption, succeeds. when add breakpoint @ onload function, it's never reached.

thank reading long post, , trying :(

ng-bind-html not compile ui-codemirror directive string.
use $sce.trustashtml(), won't able bind cmoption on scope.

i think best bet add textarea directly view. , add text scope's model.

<p>     <textarea ui-codemirror='cmoption' ng-model='tab.cmmodel'></textarea> </p> 

it's not clear trying do. if post code call formattext(text) perhaps can improve answer.

edit:

i've tweeked answer little. think need cmmodel/text property part of tab object, each tab gets own value. still see using formattext though.


Comments

Popular posts from this blog

Android : Making Listview full screen -

javascript - Parse JSON from the body of the POST -

javascript - Chrome Extension: Interacting with iframe embedded within popup -