angular - 不能绑定到“ngModel”,因为它不是“输入”的已知属性?
问题描述
完整代码是:
<input #inputSearch tabindex="0" [(ngModel)]="searchValue" (keydown.enter)="searchByClick()" type="text">
app.module 是:
@NgModule({
declarations: [],
imports: [
CommonModule,
SharedModule,
BrowserModule,
AppRoutingModule
]
)}
export class AppModule {}
怎么了,为什么它对我不起作用?
解决方案
import { FormsModule } from '@angular/forms';
import { NgModule } from "@angular/core";
在 app.module.ts 中导入 FormsModule 和 NgModule
推荐阅读
- windows - 如何从 cmd 使用默认复印机进行复制?
- html - 如何进行元重定向以重定向到存储在参数中的 URL?
- php - 使用 XMLReader 和 PHP 获取大 XML 文件中子树的数据
- reactjs - 渲染时目标容器不是 DOM 元素
- c# - Blazor 以单向方式将值绑定到“输入日期”
- javascript - react-data-grid 中的基本过滤
- ruby - Vagrant 不提供堆栈
- javascript - 按年份对 Json 数据进行分组,以便使用 amchart 创建堆积条形图
- javascript - 节点应用程序不在远程服务器上运行,在 PC 上运行
- javascript - chrome 扩展 - 根据幻数获取文件类型