[英]Can't bind to 'ngModule' since it isn't a known property of 'input'. in angular 2 asp.net core
Package.json Package.json
{
"version": "1.0.0",
"name": "asp.net",
"private": true,
"dependencies": {
"@angular/common": "2.0.0",
"@angular/compiler": "2.0.0",
"@angular/core": "2.0.0",
"@angular/forms": "2.0.0",
"@angular/http": "2.0.0",
"@angular/platform-browser": "2.0.0",
"@angular/platform-browser-dynamic": "2.0.0",
"@angular/router": "3.0.0",
"@angular/upgrade": "2.0.0",
"core-js": "^2.4.1",
"reflect-metadata": "^0.1.3",
"rxjs": "5.0.0-beta.12",
"systemjs": "0.19.27",
"zone.js": "^0.6.23",
"angular2-in-memory-web-api": "0.0.20"
},
"devDependencies": {
}
}
This is the app.module.ts 这是app.module.ts
import { NgModule } from '@angular/core';
import { BrowserModule } from '@angular/platform-browser';
import { FormsModule } from '@angular/forms';
import { LoginComponent } from "./Components/login.Component";
@NgModule({
imports: [BrowserModule, FormsModule],
declarations: [LoginComponent],
bootstrap: [LoginComponent]
})
export class AppModule { }
I have import the FormsModule in the app.module but still I am facing the issue. 我已经在app.module中导入了FormsModule ,但是仍然面临着这个问题。
This is the login.component.ts 这是login.component.ts
import { Component } from '@angular/core';
@Component({
selector: 'login-app',
templateUrl: 'Home/partialLogin'
})
export class LoginComponent {
email: string;
password: string;
constructor() {
this.email = "erere@ada.com";
this.password = "test anand";
}
login(event) {
console.log(this.email);
event.preventDefault();
}
}
login.cshtml login.cshtml
<div style="margin-bottom: 25px" class="input-group">
<span class="input-group-addon"><i class="glyphicon glyphicon-user"></i></span>
<input type="text" class="form-control" name="email" [(ngModule)] ="email" placeholder="username or email">
</div>
I have google it for the solution. 我有谷歌它的解决方案。 Everywhere they have mention to import formModule which I have already added But still facing the issue. 他们到处都提到要导入formModule,我已经添加了,但是仍然面临问题。
Please can anyone solve this issue. 请谁能解决这个问题。
It should be ngModel
not ngModule
. 应该是ngModel
而不是ngModule
。 Read more at NgModel documentation 在NgModel文档中阅读更多内容
<input type="text" class="form-control" name="email" [(ngModel)]="email" placeholder="username or email">
try this 尝试这个
<input type="text" class="form-control" name="email" [(ngModel)]="email" placeholder="username or email">
you can try [ngModel]
alone too this is called property binding but when you use [(ngModel)]
this is two way data binding 您也可以单独尝试[ngModel]
,这称为属性绑定,但是当您使用[(ngModel)]
这是两种方式的数据绑定
Where as @NgModule
is an annotation of Angular2 which allows us to fetch bundle of code/components. 其中@NgModule
是@NgModule
的注释,它使我们能够获取代码/组件包。
I hope it should be ngModel which contains the value of the input field 我希望它应该是ngModel ,其中包含输入字段的值
Where as ngModule is unlike a module in angularjs which is used to organize an application into blocks of functionality. 其中ngModule与angularjs中的模块不同,该模块用于将应用程序组织为功能块。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.