代码之家  ›  专栏  ›  技术社区  ›  Ka Tech

离子4-离子输入双向结合

  •  1
  • Ka Tech  · 技术社区  · 6 年前

    在离子4你怎么做双向绑定。在爱奥尼亚3中,我会做以下工作:

    <ion-item color="light"> <ion-input type="string" placeholder="Username" [(ngModel)]="username"></ion-input> </ion-item>
    

    Can't bind to 'ngModel' since it isn't a known property of 'ion-input'.
    1. If 'ion-input' is an Angular component and it has 'ngModel' input, then verify that it is part of this module.
    2. If 'ion-input' is a Web Component then add 'CUSTOM_ELEMENTS_SCHEMA' to the '@NgModule.schemas' of this component to suppress this message.
    3. To allow any property add 'NO_ERRORS_SCHEMA' to the '@NgModule.schemas' of this component. ("d>
              <ion-item color="light">
                  <ion-input type="string" placeholder="Username" [ERROR ->][(ngModel)]="username"></ion-input>
              </ion-item>
              <ion-item color="light">
    "): ng:///AppModule/LoginPage.html@12:62
    

    如何在离子4中工作?

    2 回复  |  直到 6 年前
        1
  •  10
  •   Deepika Wadhera    6 年前

    请记住将FormsModule添加到您的模块或创建共享模块以导入和导出FormsModule

    @NgModule({
      imports: [
        CommonModule,
        FormsModule,
        IonicModule,
        RouterModule.forChild([
          {
            path: '',
            component: HomePage
          }
        ])
      ],
      declarations: [HomePage]
    })
    export class HomePageModule { }
    
        2
  •  4
  •   Manvender Singh Rathore    6 年前

    here

    例如

    import { FormsModule } from '@angular/forms';
    
    [...]
    
    @NgModule({
      imports: [
        [...]
        FormsModule
      ],
      [...]
    })
    
        3
  •  1
  •   Tahseen Quraishi    5 年前

    你只需要导入 在里面 应用模块ts . 因为我已经给出了详细的答案。 https://stackoverflow.com/a/55684045/7983887

        4
  •  0
  •   Akhil Sivanandan    4 年前

    在角度模块中添加FormsModule

    推荐文章