[英]Can't bind to 'ngModule' since it isn't a known property of 'input'. in angular 2 asp.net core
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": {
}
}
這是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 { }
我已經在app.module中導入了FormsModule ,但是仍然面臨着這個問題。
這是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
<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>
我有谷歌它的解決方案。 他們到處都提到要導入formModule,我已經添加了,但是仍然面臨問題。
請誰能解決這個問題。
應該是ngModel
而不是ngModule
。 在NgModel文檔中閱讀更多內容
<input type="text" class="form-control" name="email" [(ngModel)]="email" placeholder="username or email">
嘗試這個
<input type="text" class="form-control" name="email" [(ngModel)]="email" placeholder="username or email">
您也可以單獨嘗試[ngModel]
,這稱為屬性綁定,但是當您使用[(ngModel)]
這是兩種方式的數據綁定
其中@NgModule
是@NgModule
的注釋,它使我們能夠獲取代碼/組件包。
我希望它應該是ngModel ,其中包含輸入字段的值
其中ngModule與angularjs中的模塊不同,該模塊用於將應用程序組織為功能塊。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.