Created
September 20, 2018 18:34
-
-
Save 1nv1n/635d0e261a76f6c1ad4f6e3e220827db to your computer and use it in GitHub Desktop.
Angular6Monaco
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
angular.json | |
... | |
"assets": [ | |
"src/assets", | |
... | |
{ "glob": "**/*", "input": "../node_modules/ngx-monaco-editor/assets/monaco", "output": "./assets/monaco/" } | |
], | |
... | |
app.module.ts | |
... | |
import { MonacoEditorModule, NgxMonacoEditorConfig } from 'ngx-monaco-editor'; | |
... | |
const monacoConfig: NgxMonacoEditorConfig = { | |
baseUrl: './assets/monaco/', | |
defaultOptions: { scrollBeyondLastLine: false }, | |
onMonacoLoad: () => { console.log((<any>window).monaco); } | |
}; | |
... | |
@NgModule({ | |
imports: [ | |
... | |
MonacoEditorModule.forRoot(monacoConfig) | |
], | |
... | |
home.component.ts | |
... | |
export class HomeComponent implements OnInit { | |
editorOptions; | |
code; | |
constructor(public overlayContainer: OverlayContainer, public electronService: ElectronService) {} | |
@HostBinding('class') componentCssClass; | |
ngOnInit() { | |
this.editorOptions = {theme: 'vs-dark', language: 'javascript'}; | |
this.code = 'function x() {\nconsole.log("Hello world!");\n}'; | |
} | |
... | |
home.component.html | |
... | |
<ngx-monaco-editor [options]="editorOptions" [(ngModel)]="code"></ngx-monaco-editor> | |
... |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment