jayralencar / ace-angular

Using Ace Editor in AngularJS
MIT License
0 stars 2 forks source link

Cannot read property 'match' of undefined #2

Open AntonioStipic opened 7 years ago

AntonioStipic commented 7 years ago

I installed ace-angular with npm and created ace editor inside angular, it looks like this:

[HTML]
<div id="editor" ace-editor="aceOptions" ng-model="aceContent"></div>

[JS]
$scope.aceOptions = {
    method: "javascript",
    theme: "monokai",
    onLoad: function(editor, session, ace){
        // Do on load
    }
}

And it keeps saying "TypeError: Cannot read property 'match' of undefined" every time I load page with ace editor. Screenshot: http://imgur.com/jFsG1KP

[AngularJS]
var app = angular.module("cloude", ["ngRoute", "ace.angular"]);

It seems that error will not appear if I remove "ace.angular" so I guess it is problem with module?

jayralencar commented 7 years ago

Can you share a example in https://jsfiddle.net/?

nickjgentile commented 5 years ago

I get this error any time we init an instance of ace-editor. It doesn't seem to cause problems for our users but it is an error. Seems to happen on this function's match. this.$detectNewLine = function(e) { var t = e.match(/^.*?(\r\n|\r|\n)/m); this.$autoNewLine = t ? t[1] : "\n", this._signal("changeNewLineMode") }

Here's an example of how we init: <div class="form-control" style="height: 400px;" ace-editor="{ mode: 'json', onLoad: aceLoaded, require: ['ace/ext/language_tools'], advanced: { enableSnippets: true, enableBasicAutocompletion: true, enableLiveAutocompletion: true }}" ng-model="data"> </div>

edswangren commented 4 years ago

A bit old, but my guess is that data isn't initialize when the editor is loaded.