ng-ace-tern
TypeScript icon, indicating that this package has built-in type declarations

1.1.0 • Public • Published

ng-ace-tern

npm package

Tern plugin for Ace Editor, suport angular2\angular4\agnular5.

Online Demo

default options

      enableBasicAutocompletion: true,
      enableLiveAutocompletion: true

default mode: javascript

default theme: chrome

Install

npm i ng-ace-tern

Sample Usage

add scripts ace-builds in your index.html or angular-cli.json

eg:

    <script src="./assets/ace-builds/src-noconflict/ace.js"></script> 
import { Component } from '@angular/core';
 
import { AceEditorDirective } from 'ng-ace-tern';
 
@Component({
  directives: [AceEditorDirective],
  template: `
  <div ace-editor
       [text]="text"
       [mode]="'sql'"
       [theme]="'clouds'"
       [options]="options"
       [readOnly]="false"
       (textChanged)="onChange($event)"
       style="display:block; height: 80vh; width:100%"></div>
  `
})
export class MyComponent {
  constructor() {
    this.text = 'test';
    this.options = { printMargin: false };
    this.onChange = (data) => {
      console.log(data);
    }
  }
}

Important pieces to note in the HTML template: [ace-editor] attribute, [text], [theme], [mode], [readOnly], [options] inputs, (textChanged) ,(editorRef) output. As per Ace, you must also make it a display: block; and give it a width and height.

Related

License

MIT


giscafer.com  ·  GitHub @giscafer  ·  Twitter @nickbinglao  ·  Weibo @Nickbing_Lao

/ng-ace-tern/

    Package Sidebar

    Install

    npm i ng-ace-tern

    Weekly Downloads

    3

    Version

    1.1.0

    License

    MIT

    Unpacked Size

    72.1 kB

    Total Files

    17

    Last publish

    Collaborators

    • giscafer