Skip to content

Commit

Permalink
Merge pull request #2 from jlmitch5/patch-1
Browse files Browse the repository at this point in the history
allow readOnly to be passed to CodeMirror
  • Loading branch information
Chris Houseknecht authored Jul 15, 2016
2 parents 7ae6822 + 02afc31 commit b94dc86
Showing 1 changed file with 10 additions and 1 deletion.
11 changes: 10 additions & 1 deletion lib/AngularCodeMirror.js
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@
angular.module('AngularCodeMirrorModule', [])

.factory('AngularCodeMirror', [ function() {
return function() {
return function(readOnly) {
var fn = function() {

this.myCodeMirror = null;
Expand Down Expand Up @@ -68,6 +68,15 @@ angular.module('AngularCodeMirrorModule', [])

// Initialize CodeMirror
self.modes[mode].value = scope[model];

// if readOnly is passed to AngularCodeMirror, set the
// options for all modes to be readOnly
if (readOnly) {
Object.keys(self.modes).forEach(function(val) {
self.modes[val].readOnly = true;
});
}

self.myCodeMirror = CodeMirror(document.getElementById('cm-' + model + '-container'), self.modes[mode]);

// Adjust the height
Expand Down

0 comments on commit b94dc86

Please sign in to comment.