gpt4 book ai didi

javascript - 无法绑定(bind)到 'ngModule',因为它不是 'input' 的已知属性。在 Angular 2 asp.net 核心

转载 作者:行者123 更新时间:2023-11-30 07:33:44 25 4
gpt4 key购买 nike

包.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();

}

}

登录.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 documentation 阅读更多内容

<input type="text" class="form-control" name="email" [(ngModel)]="email" placeholder="username or email">

关于javascript - 无法绑定(bind)到 'ngModule',因为它不是 'input' 的已知属性。在 Angular 2 asp.net 核心,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/41343454/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com