Warning: file_get_contents(/data/phpspider/zhask/data//catemap/5/fortran/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Angularjs 嵌入ngx编辑器中没有InjectionToken的提供程序_Angularjs_Angular_Typescript_Monaco Editor_Ngx Monaco Editor - Fatal编程技术网

Angularjs 嵌入ngx编辑器中没有InjectionToken的提供程序

Angularjs 嵌入ngx编辑器中没有InjectionToken的提供程序,angularjs,angular,typescript,monaco-editor,ngx-monaco-editor,Angularjs,Angular,Typescript,Monaco Editor,Ngx Monaco Editor,我正在尝试将Monaco编辑器嵌入到使用本指南开发的web应用程序中。我尝试添加ngx编辑器标记,Angular给了我这个错误。有没有办法解决这个问题 ERROR Error: Uncaught (in promise): NullInjectorError: R3InjectorError(EditorModule)[InjectionToken NGX_MONACO_EDITOR_CONFIG -> InjectionToken NGX_MONACO_EDITOR_CONFIG -&g

我正在尝试将Monaco编辑器嵌入到使用本指南开发的web应用程序中。我尝试添加
ngx编辑器
标记,Angular给了我这个错误。有没有办法解决这个问题

ERROR Error: Uncaught (in promise): NullInjectorError: R3InjectorError(EditorModule)[InjectionToken NGX_MONACO_EDITOR_CONFIG -> InjectionToken NGX_MONACO_EDITOR_CONFIG -> InjectionToken NGX_MONACO_EDITOR_CONFIG -> InjectionToken NGX_MONACO_EDITOR_CONFIG]: 
  NullInjectorError: No provider for InjectionToken NGX_MONACO_EDITOR_CONFIG!
NullInjectorError: R3InjectorError(EditorModule)[InjectionToken NGX_MONACO_EDITOR_CONFIG -> InjectionToken NGX_MONACO_EDITOR_CONFIG -> InjectionToken NGX_MONACO_EDITOR_CONFIG -> InjectionToken NGX_MONACO_EDITOR_CONFIG]: 
  NullInjectorError: No provider for InjectionToken NGX_MONACO_EDITOR_CONFIG!
    at NullInjector.get (core.js:915)
    at R3Injector.get (core.js:11082)
    at R3Injector.get (core.js:11082)
    at R3Injector.get (core.js:11082)
    at NgModuleRef$1.get (core.js:24199)
    at R3Injector.get (core.js:11082)
    at NgModuleRef$1.get (core.js:24199)
    at Object.get (core.js:22102)
    at getOrCreateInjectable (core.js:3921)
    at Module.ɵɵdirectiveInject (core.js:13753)
    at resolvePromise (zone-evergreen.js:798)
    at resolvePromise (zone-evergreen.js:750)
    at zone-evergreen.js:860
    at ZoneDelegate.invokeTask (zone-evergreen.js:399)
    at Object.onInvokeTask (core.js:27425)
    at ZoneDelegate.invokeTask (zone-evergreen.js:398)
    at Zone.runTask (zone-evergreen.js:167)
    at drainMicroTaskQueue (zone-evergreen.js:569)
这是我的组件。ts

import {Component, OnInit} from '@angular/core';



@Component({
  selector: 'app-text-editor',
  templateUrl: './text-editor.component.html',
  styleUrls: ['./text-editor.component.scss']
})
export class TextEditorComponent implements OnInit {

  editorOptions = {theme: 'vs-dark', language: 'javascript'};
  code: string= 'function x() {\nconsole.log("Hello world!");\n}';

  constructor() {
  }

  ngOnInit() {
  }
}

我已经通过安装v9.0.0解决了glob目录问题,但是这个错误让我陷入了相当长的一段时间


编辑通过将.forRoot添加到AppModule导入中解决。我的错!我想我已经添加了它

请确保
monaceditormodule.forRoot()
在你的AppModule中。

你在AppModule中添加了
monaceditormodule.forRoot()
吗?哦!实际上我忘了添加.forRoot()。非常感谢。