相关文章推荐
拉风的猕猴桃  ·  digital ...·  1 年前    · 
侠义非凡的剪刀  ·  SQL ...·  1 年前    · 
The indentation tries to be somewhat "do what I mean"... but might not match your style. <body> The indentation tries to be <em>somewhat &quot;do what I mean&quot;</em>... but might not match your style. </body> </html>
<section ng-controller="CodemirrorCtrl">
  <textarea ui-codemirror="cmOption" ng-model="cmModel"></textarea>
  Mode : <select ng-model="mode" ng-options="m for m in modes" ng-change="modeChanged()"></select>
</section>
// The modes $scope.modes = ['Scheme', 'XML', 'Javascript']; $scope.mode = $scope.modes[0]; // The ui-codemirror option $scope.cmOption = { lineNumbers: true, indentWithTabs: true, onLoad : function(_cm){ // HACK to have the codemirror instance in the scope... $scope.modeChanged = function(){ _cm.setOption("mode", $scope.mode.toLowerCase()); // Initial code content... $scope.cmModel = ';; Scheme code in here.\n' + '(define (double x)\n\t(* x x))\n\n\n' + '<!-- XML code in here. -->\n' + '<root>\n\t<foo>\n\t</foo>\n\t<bar/>\n</root>\n\n\n' + '// Javascript code in here.\n' + 'function foo(msg) {\n\tvar r = Math.random();\n\treturn "" + r + " : " + msg;\n}';