demo/demo.html
<section id="codemirror" ng-app="doc.ui-codeMirror">
<!-- =Minimal code
--------------------------------------------------------------------------- -->
<div id="demo-mini">
<div class="page-header">
<h1>Minimal code</h1>
</div>
<div class="row">
<div class="col-md-6">
<div ui-codemirror>Code mirror here</div>
</div>
<div class="col-md-6" ng-controller="PlunkerCtrl"
ng-init="
vendor_css=['http://codemirror.net/lib/codemirror.css'];
vendor_js=['http://codemirror.net/lib/codemirror.js'];
"
>
<div class="pull-right">
<button class="btn btn-info" ng-click="edit('1.2.6', 'UI.Codemirror', 'ui-codemirror')">
<i class="glyphicon glyphicon-edit"></i> Edit in plunker
</button>
</div>
<tabset>
<tab heading="Markup">
<div plunker-content="markup">
<pre class="prettyprint"><section>
<div ui-codemirror >Code mirror here</div>
</section></pre>
</div>
</tab>
</tabset>
</div>
</div>
</div>
<!-- =General options demo
--------------------------------------------------------------------------- -->
<div id="demo-general">
<div class="page-header">
<h1>General options</h1>
</div>
<div class="row">
<div class="col-md-6">
<div ui-codemirror="{
lineNumbers: true,
theme:'twilight',
readOnly: 'nocursor',
lineWrapping : true,
mode: 'xml'
}"><html style="color: green">
<!-- this is a comment -->
<head>
<title>HTML Example</title>
</head>
<body>
The indentation tries to be <em>somewhat &quot;do what
I mean&quot;</em>... but might not match your style.
</body>
</html></div>
</div>
<div class="col-md-6" ng-controller="PlunkerCtrl"
ng-init="
vendor_css=['http://codemirror.net/lib/codemirror.css', 'http://codemirror.net/theme/twilight.css'];
vendor_js=['http://codemirror.net/lib/codemirror.js', 'http://codemirror.net/mode/xml/xml.js'];
"
>
<div class="pull-right">
<button class="btn btn-info" ng-click="edit('1.2.6', 'UI.Codemirror', 'ui-codemirror')">
<i class="glyphicon glyphicon-edit"></i> Edit in plunker
</button>
</div>
<tabset>
<tab heading="Markup">
<div plunker-content="markup">
<pre class="prettyprint"><section>
<div ui-codemirror="{
lineNumbers: true,
theme:'twilight',
readOnly: 'nocursor',
lineWrapping : true,
mode: 'xml'
}" >&lt;html style=&quot;color: green&quot;&gt;
&lt;!-- this is a comment --&gt;
&lt;head&gt;
&lt;title&gt;HTML Example&lt;/title&gt;
&lt;/head&gt;
&lt;body&gt;
The indentation tries to be &lt;em&gt;somewhat &amp;quot;do what
I mean&amp;quot;&lt;/em&gt;... but might not match your style.
&lt;/body&gt;
&lt;/html&gt;</div>
</section></pre>
</div>
</tab>
</tabset>
</div>
</div>
</div>
<!-- =Mode-Changing demo
--------------------------------------------------------------------------- -->
<div id="demo-mode-changing">
<div class="page-header">
<h1>Mode-Changing demo</h1>
</div>
<div class="row" ng-controller="CodemirrorCtrl">
<div class="col-md-12">
<div ui-codemirror="cmOption" ng-model="cmModel"></div>
</div>
<div class="col-md-6">
Mode : <select class="form-control" ng-model="mode" ng-options="m for m in modes" ng-change="modeChanged()"></select>
</div>
</div>
</div>
<hr>
<div class="row">
<div class="span12" ng-controller="PlunkerCtrl"
ng-init="
vendor_css=['http://codemirror.net/lib/codemirror.css'];
vendor_js=['http://codemirror.net/lib/codemirror.js', 'http://codemirror.net/mode/scheme/scheme.js', 'http://codemirror.net/mode/javascript/javascript.js', 'http://codemirror.net/mode/xml/xml.js'];
"
>
<div class="pull-right">
<button class="btn btn-info" ng-click="edit('1.2.6', 'UI.Codemirror', 'ui-codemirror')">
<i class="glyphicon glyphicon-edit"></i> Edit in plunker
</button>
</div>
<tabset>
<tab heading="Markup">
<div plunker-content="markup">
<pre class="prettyprint"><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></pre>
<div style="margin-top: 450px;"></div>
</div>
</tab>
<tab heading="JavaScript">
<div plunker-content="javascript">
<pre class="prettyprint">app.controller('CodemirrorCtrl', ['$scope', function($scope) {
// 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}';
}]);</pre>
</div>
</tab>
</tabset>
</div>
</div>
</section>