angular-ui / ui-codemirror

This directive allows you to add CodeMirror to your textarea elements.
http://angular-ui.github.io/ui-codemirror
MIT License
378 stars 193 forks source link

$timeout doesn't like being called with codemirror.refresh #83

Closed 43081j closed 9 years ago

43081j commented 9 years ago

Your recent commits merged a PR in which added a $timeout call here: https://github.com/angular-ui/ui-codemirror/blob/master/src/ui-codemirror.js#L143

I find when this gets called, there are cases where this is undefined somehow, in codemirror.refresh.

This seems to be fixed easily by passing a function:

$timeout(function() {
    codeMirror.refresh();
});

I am unsure why this happens, but it completely breaks in my case when calling $apply shortly after initialisation.