当前位置: 首页 > 知识库问答 >
问题:

Angular2-不能绑定到'ng模型‘不是一个已知的属性[重复]

狄奕
2023-03-14

在我的@NGModule中,我有导入FormsModule和ReactiveFormsModule。但我仍然得到以下错误:

zone.js?1477571032896:355 Unhandled Promise rejection: Template parse errors:
Can't bind to 'ngModel' since it isn't a known property of 'p-editor'.
1. If 'p-editor' is an Angular component and it has 'ngModel' input, then verify that it is part of this module.
2. If 'p-editor' is a Web Component then add "CUSTOM_ELEMENTS_SCHEMA" to the '@NgModule.schemas' of this component to suppress this message.

</p-editor>"): MainComponent@2:40
No provider for NgControl ("

[ERROR ->]<p-editor formControlName="description" [(ngModel)]="text" (onTextChange)="onTextChange($event)" [sty"): MainComponent@2:0

如果我尝试使用[(ngModel)]绑定,这也会发生在正常的情况下,比如输入

<p-editor formControlName="description" [(ngModel)]="text" (onTextChange)="onTextChange($event)" [style]="{'height':'200px'}">
http://www.primefaces.org/primeng/#/editor
imports: [
              BrowserModule,
              FormsModule,
              ReactiveFormsModule,
import { EditorModule, SharedModule, ButtonModule, TabMenuModule } from 'primeng/primeng';

它们被添加到进口商品中

共有1个答案

陆和泰
2023-03-14

只需在app.module.ts文件中添加FormsModule,如下所示,它对我有效,希望对你也有效

import { NgModule } from '@angular/core';
import { BrowserModule } from '@angular/platform-browser';
import { FormsModule } from '@angular/forms';
import { AppComponent } from './app.component';

@NgModule({
imports: [ BrowserModule, FormsModule ],
declarations: [ AppComponent ],
bootstrap: [ AppComponent ]
})

export class AppModule { }
 类似资料: