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
- Host: GitHub
- URL: https://github.com/yabab-dev/ng2-codemirror
- Owner: yabab-dev
- License: mit
- Created: 2016-07-10T20:21:07.000Z (almost 10 years ago)
- Default Branch: master
- Last Pushed: 2019-11-25T19:36:37.000Z (over 6 years ago)
- Last Synced: 2025-06-14T18:58:09.475Z (about 1 year ago)
- Language: TypeScript
- Size: 22.5 KB
- Stars: 70
- Watchers: 5
- Forks: 30
- Open Issues: 23
-
Metadata Files:
- Readme: README.md
- License: LICENSE
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/
- 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`
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...`;
}
}
```
* `config` : The configuration object for CodeMirror see http://codemirror.net/doc/manual.html#config