angular - Angular 4 - 无法绑定到“ngmodel”,因为它不是“输入”的已知属性。("
问题描述
下面是代码片段,即使在导入 Formmodule 后我也遇到了错误,它没有解决
app.module.ts
import { BrowserModule } from '@angular/platform-browser';
import {NgModule} from '@angular/core';
import {FormsModule} from '@angular/forms';
import {AppComponent} from './app.component';
import{firstComponent} from './first/first.component';
import { SecondComponent } from './second/second.component';
@NgModule({
declarations: [
AppComponent,
firstComponent,
SecondComponent
],
imports: [
BrowserModule,
FormsModule
],
Sec.component.html
==================
<input type="text" [(ngmodel)]="TwoWayData" [value]="TwoWayData" name="" >
{{TwoWayData}}
Sec.component.ts
TwoWayData:string='Fortune';
解决方案
你的问题在这里,在 [(ngmodel)] M 是大写
[(ngmodel)]="TwoWayData"
代替它
<input type="text" [(ngModel)]="TwoWayData" [value]="TwoWayData" name="">
{{TwoWayData}}
推荐阅读
- c# - Microsoft Graph API 调用无限期挂起
- php - 是否可以将带有数据库值的选择输入放入动态添加/删除输入字段中?
- sql - 将字符串分成名字、姓氏、地址等
- c# - 我正在创建一个巡逻 AI,它会激怒玩家并在 Unity 3D 中跟随他们
- git - 为什么 git diff 在两个分支上都相同时会考虑某些更改?
- linkedin - 在对 Linkedin V2 API 的请求中总是返回哪个名字字段?
- google-analytics - Bigquery - 计算添加到购物车的数量
- c++ - 使用 C++ 中的 Lua,无法打开标准库并出现 Nil 错误
- asp.net - 如何使用 ASP.NET MVC 中的请求标头对具有 Oauth2 授权的 API 进行 HTTP get 调用?
- angular - Angular 材质中的奇怪行为