0.3.9 • Published 6 years ago
ng2-ace-editor v0.3.9
ng2-ace-editor
Ace editor integration with typescript for angular 5.
To use Angular 4 install version 0.3.1 (npm i -S ng2-ace-editor@0.3.1).
Install
npm i -S ng2-ace-editor
Load the module for your app:
import { AceEditorModule } from 'ng2-ace-editor';
@NgModule({
...
imports: [
...
AceEditorModule
]
})
Use directive
Minimal
//import { AceEditorModule } from 'ng2-ace-editor';
import { Component } from '@angular/core';
@Component({
template: `
<div ace-editor
[(text)]="text" // possible two way binding (thx ChrisProlls)
></div>
`
})
export class MyComponent {
text:string = "";
}
Complete
import { Component } from '@angular/core';
//to use theme "eclipse"
//with angular-cli add "../node_modules/ace-builds/src-min/ace.js"
//and "../node_modules/ace-builds/src-min/theme-eclipse.js" to "scripts" var into the file angular-cli.json
@Component({
template: `
<div ace-editor
[(text)]="text" // possible two way binding (thx ChrisProlls)
[mode]="'sql'" //string or object (thx ckiffel)
[theme]="'eclipse'"
[options]="options"
[readOnly]="false"
[autoUpdateContent]="true" //change content when [text] change
[durationBeforeCallback]="1000" //wait 1s before callback 'textChanged' sends new value
(textChanged)="onChange($event)"
style="min-height: 200px; width:100%; overflow: auto;"></div>
`
})
export class MyComponent {
text:string = "";
options:any = {maxLines: 1000, printMargin: false};
onChange(code) {
console.log("new code", code);
}
}
Use Component
import {Component, ViewChild} from '@angular/core';
//to use theme eclipse
//with angular-cli add "../node_modules/ace-builds/src-min/ace.js"
//and "../node_modules/ace-builds/src-min/theme-eclipse.js" to "scripts" var into the file angular-cli.json
@Component({
template: `
<ace-editor
[(text)]="text" // possible two way binding (thx ChrisProlls)
#editor style="height:150px;"></ace-editor>
`
})
export class AceCmp {
@ViewChild('editor') editor;
text: string = "";
ngAfterViewInit() {
this.editor.setTheme("eclipse");
this.editor.getEditor().setOptions({
enableBasicAutocompletion: true
});
this.editor.getEditor().commands.addCommand({
name: "showOtherCompletions",
bindKey: "Ctrl-.",
exec: function (editor) {
}
})
}
}
Power by
0.3.9
6 years ago
0.3.8
7 years ago
0.3.7
7 years ago
0.3.6
7 years ago
0.3.5
7 years ago
0.3.4
7 years ago
0.3.3
7 years ago
0.3.2
7 years ago
0.3.1
7 years ago
0.3.0
7 years ago
0.2.5
7 years ago
0.2.4
7 years ago
0.2.3
8 years ago
0.2.2
8 years ago
0.2.1
8 years ago
0.2.0
8 years ago
0.1.9
8 years ago
0.1.8
8 years ago
0.1.7
8 years ago
0.1.6
8 years ago
0.1.5
8 years ago
0.1.4
8 years ago
0.1.3
8 years ago
0.1.2
8 years ago
0.1.1
8 years ago
0.1.0
8 years ago
0.0.21
8 years ago
0.0.20
8 years ago
0.0.19
8 years ago
0.0.18
8 years ago
0.0.17
8 years ago
0.0.16
8 years ago
0.0.14
8 years ago
0.0.13
8 years ago