An open API service indexing awesome lists of open source software.

https://github.com/yabab-dev/ng2-codemirror

Angular2 CodeMirror component
https://github.com/yabab-dev/ng2-codemirror

Last synced: 12 months ago
JSON representation

Angular2 CodeMirror component

Awesome Lists containing this project

README

          

# Angular - Codemirror component

Use the [CodeMirror (5.x)](http://codemirror.net/) code editor in your Angular application.

**Demo** : https://embed.plnkr.co/8e9gxss9u10VeFrv29Zt/

### Installation

- Include Codemirror javascript files in your application (with files for modes)
- Install ng2-codemirror
- JSPM : `jspm install npm:ng2-codemirror`
- NPM : `npm install ng2-codemirror`

### Dependencies
CodeMirror library is required for this component :
- Install via NPM : `npm install codemirror`
- Install via JSPM : `jspm install npm:codemirror`

CodeMirror need to be accessible by `import 'codemirror'`

Then you need to include base CSS of codemirror located in `codemirror/lib/codemirror.css`

### Sample

Include `CodemirrorModule` in your main module :

```javascript
import { CodemirrorModule } from 'ng2-codemirror';

@NgModule({
// ...
imports: [
CodemirrorModule
],
// ...
})
export class AppModule { }
```

```javascript
import { Component } from 'angular2/core';

@Component({
selector: 'sample',
template: `


`
})
export class Sample{
constructor(){
this.code = `// Some code...`;
}
}
```

### Configuration

* `config` : The configuration object for CodeMirror see http://codemirror.net/doc/manual.html#config

### Licence
See `LICENSE` file