【问题标题】:Can't bind to 'value' since it isn't a known property of 'ngs-code-editor'无法绑定到“值”,因为它不是“ngs-code-editor”的已知属性
【发布时间】:2021-06-05 08:36:12
【问题描述】:

我已经在 Angular 模块中导入了以下几行并且也导入了。但仍然出现以下错误 错误 NG8002:无法绑定到“值”,因为它不是“ngs-code-editor”的已知属性。

  1. 如果“ngs-code-editor”是一个 Angular 组件并且它具有“值”输入,则验证它是该模块的一部分。
  2. 如果“ngs-code-editor”是 Web 组件,则将“CUSTOM_ELEMENTS_SCHEMA”添加到该组件的“@NgModule.schemas”以禁止显示此消息。
  3. 要允许任何属性将“NO_ERRORS_SCHEMA”添加到此组件的“@NgModule.schemas”。

从'@ngstack/code-editor'导入{ CodeEditorModule }; 从“@angular/forms”导入 { FormsModule };

导入:[CodeEditorModule.forRoot() ,FormsModule ],

  <ngs-code-editor style="height:90%;width:100%"
  theme="vs-light" 
  
  [(value)]="code"
  language="typescript"
 
  [options]="options"
  (valueChanged)="onrqCodeChanged($event)">
</ngs-code-editor>

【问题讨论】:

    标签: angular


    【解决方案1】:

    发生此错误是因为 Angular 找不到 CodeEditorModule

    例如,如果CodeEditorModule.forRoot() 被导入到您的component.module.ts 中,请确保您在AppModule 中导入ComponentModule

    【讨论】:

    • 是的,我在应用程序模块中导入了组件 import { CodeEditorModule } from '@ngstack/code-editor';从'./app.component'导入{AppComponent}; @NgModule({声明:[AppComponent],导入:[BrowserModule,AppRoutingModule,BrowserAnimationsModule,ContextMenuModule.forRoot(),TabsModule.forRoot(),NgJsonEditorModule,HttpClientModule,CodeEditorModule.forRoot(),FormsModule,NgxCSVtoJSONModule],提供者:[] ,引导程序:[AppComponent] })
    猜你喜欢
    • 2022-01-09
    • 2017-06-21
    • 2017-02-03
    • 1970-01-01
    • 1970-01-01
    • 2019-10-10
    • 1970-01-01
    • 1970-01-01
    • 2019-08-26
    相关资源
    最近更新 更多