简体   繁体   English

无法绑定到“ ngModule”,因为它不是“ input”的已知属性。 在angular 2 asp.net核心中

[英]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. 其中ngModuleangularjs中的模块不同,该模块用于将应用程序组织为功能块。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 无法绑定到“ngModel”,因为它不是“输入”的已知属性 - Can't bind to 'ngModel' since it isn't a known property of 'input' Angular 7:无法绑定到“元素”,因为它不是 - Angular 7 : Can't bind to 'element' since it isn't a known property of 无法绑定到“”,因为它不是“ angular 2”的已知属性 - can't bind to '' since it isn't a known property of '' angular 2 无法绑定到((ngModel),因为在角度单位测试用例中它不是&#39;input&#39;的已知属性 - Can't bind to '(ngModel' since it isn't a known property of 'input' in angular unit test case 无法绑定到“ngModel”,因为它不是“输入”的已知属性,如何在 angular 9 中修复? - Can't bind to 'ngModel' since it isn't a known property of 'input', how to fix in angular 9? 带有 Angular 的 NG2 图表:无法绑定到“颜色”,因为它不是 Angular 中“画布”的已知属性 13 - NG2 Chart with Angular: Can't bind to 'colors' since it isn't a known property of 'canvas' in Angular 13 无法绑定到“控件”,因为它不是(myComponent)的已知属性 - Can't bind to 'control' since it isn't a known property of (myComponent) 无法绑定到“ useStickyClasses”,因为它不是“ div”的已知属性 - Can't bind to 'useStickyClasses' since it isn't a known property of 'div' 无法绑定到“matMenuTrigger”,因为它不是“a”的已知属性 - Can't bind to 'matMenuTrigger' since it isn't a known property of 'a' 无法绑定到“数据集”,因为它不是“画布”的已知属性 - Can't bind to 'datasets' since it isn't a known property of 'canvas'
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM