Ace editor in Angular 2 and Autocomplete

536 views
Skip to first unread message

Eden Shalom

unread,
Dec 21, 2016, 7:56:01 PM12/21/16
to Ajax.org Cloud9 Editor (Ace)
Hi all,
I'm trying to set up an ace editor as an Angular2 component and it works pretty well. 
The issue I have is with Autocomplete. I need my ace to respond on autocomplete hitting dot (.)
It used to work for me by adding the following code: 

editor.commands.on("afterExec", function(e){ 
     if (e.command.name == "insertstring"&&/^[\w.]$/.test(e.args)) { 
         editor.execCommand("startAutocomplete") 
     } 
})


But doing similar with angular class I'm getting the this.editor undefined executing this.editor.execCommand("startAutocomplete") 

if (e.command.name == "insertstring"&&/^[\w.]$/.test(e.args)) {
                  this.editor.execCommand("startAutocomplete");
           } 
       }) 


Any idea of how can I solve this?
And insight, advice, or guidance would be greatly appreciated. Thanks!!!

My sample code: 


Harutyun Amirjanyan

unread,
Dec 22, 2016, 6:20:30 AM12/22/16
to ace-d...@googlegroups.com
try using

     editor.commands.on("afterExec", function(e, editor) { 

Eden Shalom

unread,
Dec 23, 2016, 8:42:59 AM12/23/16
to Ajax.org Cloud9 Editor (Ace)
Thank you Harutyun!


figured this out, it should be:
this.editor.commands.on("afterExec", function(e){
if (e.command.name == "insertstring"&&/^[\w.]$/.test(e.args)) {
e.editor.execCommand("startAutocomplete");
}
})

ajo john

unread,
Aug 17, 2017, 2:01:15 PM8/17/17
to Ajax.org Cloud9 Editor (Ace)
Can I know how did you enable the auto completion in ace editor.
Reply all
Reply to author
Forward
0 new messages