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

https://github.com/angular-ui/ui-codemirror

I need to make a syntax highlighter in angular and save the results ina database.

I am using ui-codemirror but I cannot make it to refresh the textarea everytime that I change the "pre" in the docs it says

<textarea ui-codemirror ng-model="x" ui-refresh='isSomething'></textarea>

but I cannot make it work.

anyone has any idea on how to do this?

share|improve this question
    
can you post more code, or provide a live demo reproducing this? – Eliran Malka Mar 14 '14 at 12:33

I had the same issue and could not figure out a solution for a while.

The CodeMirror instance will be updated once a scope variable/function returns true. That can be determined by a function doing a calculation on the value being displayed, but in my snippet I have my data updated from the result of a broadcasted event. I set the scope variable to be checked to true, and then with a short delay, I change it back to false.

$scope.$on(ART_EVENTS.updateOverview, function (event, data) {
    $log.info("received overviewData in articleController.");

    // do stuff with the data
    // ...

    $scope.refreshCodemirror = true;
    $timeout(function () {
      $scope.refreshCodemirror = false;
    }, 100);
});

And then in the view:

<textarea ui-codemirror ng-model="x" ui-refresh='refreshCodemirror'></textarea>

I do realise that there might be better solutions, but this works for what I need.

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.