gpt4 book ai didi

javascript - ionic 切换检查属性

转载 作者:行者123 更新时间:2023-12-03 06:20:18 25 4
gpt4 key购买 nike

我正在使用 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')

最佳答案

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

关于javascript - ionic 切换检查属性,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/38902637/

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