代码之家  ›  专栏  ›  技术社区  ›  tarek noaman

无法绑定到“ngModel”,因为它不是具有pug的“input”angular 5的已知属性

  •  1
  • tarek noaman  · 技术社区  · 7 年前

    我在启动Angular应用程序时出现以下错误。 这个问题只有在我使用pug时才会发生,但代码在html中运行良好。

    这是我的应用程序。单元输电系统

    import { BrowserModule } from '@angular/platform-browser';
    import { NgModule } from '@angular/core';
    import { FormsModule } from '@angular/forms'; 
    import { AppComponent } from './app.component'; 
    import { HeroesComponent } from './heroes/heroes.component'; 
    
    @NgModule({
      imports: [
        BrowserModule,
        FormsModule
      ],
      declarations: [
        AppComponent,  
        HeroesComponent, 
      ], 
      bootstrap: [AppComponent]
    })
    export class AppModule { }
    

    这是我的哈巴狗

    h2 {{ hero.name | uppercase}} Details
    div
      span id: 
      | {{hero.id}}
    div
      span name: 
      | {{hero.name}}
    
    
    input([(ngmodel)]='hero.name', placeholder='name') 
    

    你知道如何转换这条线,让angular理解这条线吗 input([(ngmodel)]='hero.name', placeholder='name')

    2 回复  |  直到 7 年前
        1
  •  5
  •   Vivek Doshi    7 年前

    区分大小写的错误coz:

    它是 ngModel ngmodel .


    因此,改变:

    input([(ngmodel)]='hero.name', placeholder='name') 
    

    收件人:

    input([(ngModel)]='hero.name', placeholder='name') 
    
        2
  •  0
  •   mruanova    7 年前

    请使用正确的语法([ngModel]而不是[(ngModel)]

    推荐文章