Join the Stack Overflow Community
Stack Overflow is a community of 6.5 million programmers, just like you, helping each other.
Join them; it only takes a minute:
Sign up

In codemirror-ui I want to execute one of the commands described here: https://codemirror.net/doc/manual.html#commands

I have the following code:

<ui-codemirror ui-codemirror-opts="editorOptions" ng-model="model"/>
<input type="button" ng-click="selectAll()" value="Select All"/>

Controller:

$scope.selectAll = new function() {
    // how to cm.execCommand('selectAll')?
}
share|improve this question

To execute command or executed any method in codemirror using angularjs , you have to select the instance of the codemirror, something like this.

var codeMirrorInstance = angular.element('#idCodemirror').CodeMirror;

after that do you have access over all that method

codeMirrorInstance.refresh();

codeMirrorInstance.setSelection( {line: codeMirrorInstance.firstLine(), ch: 0},  {line: codeMirrorInstance.lastLine()+1, ch: 0});
share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.