# ng2-ace-editor

> Ace editor integration with typescript for Angular.

Latest version **0.3.9** (published 2019-01-16) · MIT license · 0 weekly downloads

## Install

```sh
npm install ng2-ace-editor
pnpm add ng2-ace-editor
yarn add ng2-ace-editor
bun add ng2-ace-editor
```

## Health

**Score 25/100 (F)** — status: abandoned.

Positive: has types; esm support; no vulnerabilities.

Warnings: low downloads; pre 1.0.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 0.3.9 |
| Published | 2019-01-16 |
| First published | 2016-08-08 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | bundled |
| Module format | ESM + CommonJS |
| Dependencies | 2 |
| Unpacked size | 93.6 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 197 |
| Author | François-Xavier Montigny |
| Maintainers | fxmontigny, use-code |
| Keywords | angular5, angular cli, ace, brace, typescript, directive, component, editor, ng2-ace, angular2-ace |

## Links

- npm: https://www.npmjs.com/package/ng2-ace-editor
- Repository: https://github.com/fxmontigny/ng2-ace-editor
- Homepage: https://github.com/fxmontigny/ng2-ace-editor#readme
- Issues: https://github.com/fxmontigny/ng2-ace-editor/issues
- npm.io page: https://npm.io/package/ng2-ace-editor

## Dependencies (2)

- [brace](https://npm.io/package/brace.md) ^0.11.1
- [ace-builds](https://npm.io/package/ace-builds.md) ^1.4.2

## Alternatives

- [@openai/codex-sdk](https://npm.io/package/@openai/codex-sdk.md) — 731.4K weekly downloads
- [babel-plugin-transform-react-jsx](https://npm.io/package/babel-plugin-transform-react-jsx.md) — 565.0K weekly downloads
- [babel-helper-remove-or-void](https://npm.io/package/babel-helper-remove-or-void.md) — 508.5K weekly downloads
- [@pnpm/store-controller-types](https://npm.io/package/@pnpm/store-controller-types.md) — 186.9K weekly downloads
- [react-native-signature-canvas](https://npm.io/package/react-native-signature-canvas.md) — 155.6K weekly downloads

## Recent versions

- 0.3.9 (latest) — 2019-01-16
- 0.3.8 — 2018-06-14
- 0.3.7 — 2018-04-20
- 0.3.6 — 2018-04-20
- 0.3.5 — 2018-04-19
- 0.3.4 — 2017-12-04
- 0.3.3 — 2017-11-26
- 0.3.2 — 2017-11-24
- 0.3.1 — 2017-09-22
- 0.3.0 — 2017-09-21
- 0.2.5 — 2017-07-31
- 0.2.4 — 2017-07-31
- 0.2.3 — 2017-06-19
- 0.2.2 — 2017-05-05
- 0.2.1 — 2017-05-04
- … 19 more at https://npm.io/package/ng2-ace-editor/versions

## README

# ng2-ace-editor

[![npm version](https://badge.fury.io/js/ng2-ace-editor.svg)](https://www.npmjs.com/package/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:

```javascript
import { AceEditorModule } from 'ng2-ace-editor';

@NgModule({
  ...
  imports: [
    ...
    AceEditorModule
  ]
})
```

# Use directive

> Minimal

```js
//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

```js
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

```js
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
[Use Code](http://www.use-code.com)

---
_Source: https://npm.io/package/ng2-ace-editor · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
