【发布时间】:2021-11-04 12:49:15
【问题描述】:
不知何故,我收到错误“无法绑定到 'ngModel',因为它不是“输入”的已知属性。 甚至 FormsModule 也是 importet。
html (login.component.html):
<input type="text" [(ngModel)] = "username">
<button (click)="login()">LOGIN DO</button>
app.module.ts:
import { FormsModule } from '@angular/forms';
@NgModule({
declarations: [
AppComponent,
ButtonsComponent,
ButtonPipe
],
imports: [
BrowserModule,
AppRoutingModule,
FormsModule,
FeatureEagerModule,
CoreModule,
HttpClientModule,
LoginComponent
],
providers: [LoginComponent],
bootstrap: [AppComponent]
})
export class AppModule { }
只是为了确保我还在 login.module.ts 中导入了 FormsModule,但即使这样也无法解决错误。
【问题讨论】:
-
请澄清您的具体问题或提供更多详细信息以准确突出您的需求。正如目前所写的那样,很难准确地说出你在问什么。
标签: html angular typescript components ngmodel