user1698109
user1698109

Reputation: 87

Can't bind to 'value' since it isn't a known property of 'ngs-code-editor'

I have imported the following lines in angular module and also imported.but still getting following error error NG8002: Can't bind to 'value' since it isn't a known property of 'ngs-code-editor'.

  1. If 'ngs-code-editor' is an Angular component and it has 'value' input, then verify that it is part of this module.
  2. If 'ngs-code-editor' is a Web Component then add 'CUSTOM_ELEMENTS_SCHEMA' to the '@NgModule.schemas' of this component to suppress this message.
  3. To allow any property add 'NO_ERRORS_SCHEMA' to the '@NgModule.schemas' of this component.

import { CodeEditorModule } from '@ngstack/code-editor'; import { FormsModule } from "@angular/forms";

imports: [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>

Upvotes: 3

Views: 1629

Answers (2)

toujames
toujames

Reputation: 465

value is no longer an attribute in the new version.

You have to use d codeModel instead.

In your .html:

<ngs-code-editor [theme]="theme"
                 [codeModel]="codeModel" 
                 [options]="options"
                 (valueChanged)="onCodeChanged($event)">
</ngs-code-editor>

in your .ts


codeModel: CodeModel = {
    language: 'json',
    uri: 'main.json',
    value: '{}',
};

Upvotes: 0

Nam Dao
Nam Dao

Reputation: 409

This error occurred because Angular couldn't find the CodeEditorModule.

For example, if the CodeEditorModule.forRoot() is imported in your component.module.ts, make sure you import ComponentModule within your AppModule.

Upvotes: 1

Related Questions