Closed nadersoliman closed 9 years ago
I made a directive to address this issue
.directive('cmlCodemirrorRefresh', [
'$timeout'
($timeout) ->
###
usage: <textarea ui-codemirror="options" ng-model="obj.samples_json" class="cml-codemirror-refresh"></textarea>
###
restrict: 'C'
link: (scope, element, attrs)->
attrs.$observe 'ngModel', (value) ->
#console.log 'to watch', value
scope.$watch value, (newValue)->
#console.log 'for ', value, 'got new value', newValue
$timeout ->
#console.log 'refreshing codemirror element', element.next()
element.next()[0].CodeMirror.refresh()
, 100
])
Same issue with ui-codemirror + AngularStrap tabs combination.
This fix worked for me:
if (newVal !== oldVal) {
$timeout(function() {
codeMirror.refresh();
});
}
In lieu of issues #41 and #55 I had codemirror inside a tab. It is not refreshing despite adding ui-refresh attribute with proper model name something like
Introducing the following patch fixed for me, and I guess it will fix it for others
$timeout(function(){codeMirror.refresh();}, 100);
@ https://github.com/angular-ui/ui-codemirror/blob/8b6b3b002a144a17216d34560ca415576c2b8bf4/src/ui-codemirror.js#L101