【问题标题】:Ion-toggle checked attribute离子切换检查属性
【发布时间】:2016-12-18 13:30:57
【问题描述】:

我正在使用 Ionic 2 和 Angular 2 beta 11。

如何关闭拨动开关?查看 Ionic documentation,它建议使用 checked 属性。但是,我已经尝试过这个以及ng-checked,但没有成功。

有什么建议吗?

<ion-item>
  <ion-label>Drivers Licence</ion-label>
  <ion-toggle checked="false" id="driversLicence" formControlName="driversLicence">Drivers Licence</ion-toggle>
</ion-item>

更新:

好像我有formControlName="driversLicence",切换开关总是打开。这是为什么?因为我需要formControlName,我怎样才能让它工作?

我需要访问driversLicence,我这样做如下:

this.jobdetailsForm.value.driversLicence

在提交表单时如何在不使用formControlName 的情况下获取driversLicence 值?我尝试以下,但它是null

document.getElementById('driverLicence')

【问题讨论】:

  • 好像我有formControlName="driversLicence",切换开关总是打开的。这是为什么?因为我需要formControlName,我怎样才能让它工作?

标签: javascript angularjs angular ionic-framework ionic2


【解决方案1】:

使用[(ngModel)] 解决。这将它与模型对象联系起来

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2018-04-23
    • 1970-01-01
    • 2018-07-12
    • 2023-03-30
    • 2017-12-05
    • 1970-01-01
    • 2020-11-10
    • 1970-01-01
    相关资源
    最近更新 更多