155 |
app.controller('CodemirrorCtrl', ['$scope', function($scope) {
156 |
157 | // The modes
158 | $scope.modes = ['Scheme', 'XML', 'Javascript'];
159 | $scope.mode = $scope.modes[0];
160 |
161 |
162 | // The ui-codemirror option
163 | $scope.cmOption = {
164 | lineNumbers: true,
165 | indentWithTabs: true,
166 | onLoad : function(_cm){
167 |
168 | // HACK to have the codemirror instance in the scope...
169 | $scope.modeChanged = function(){
170 | _cm.setOption("mode", $scope.mode.toLowerCase());
171 | };
172 | }
173 | };
174 |
175 |
176 |
177 | // Initial code content...
178 | $scope.cmModel = ';; Scheme code in here.\n' +
179 | '(define (double x)\n\t(* x x))\n\n\n' +
180 | '<!-- XML code in here. -->\n' +
181 | '<root>\n\t<foo>\n\t</foo>\n\t<bar/>\n</root>\n\n\n' +
182 | '// Javascript code in here.\n' +
183 | 'function foo(msg) {\n\tvar r = Math.random();\n\treturn "" + r + " : " + msg;\n}';
184 |
185 | }]);
186 |
187 |