如何在角度6中选中默认复选框? [英] How to make default checkbox checked in angular 6?
本文介绍了如何在角度6中选中默认复选框?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
lanuage.component.html
lanuage.component.html
<form method="post" enctype="multipart/form-data">
<mat-checkbox class="versionstyle" name="languageenabled"[(ngModel)]="languageObj.languageenabled">Enabled</mat-checkbox>
</form>
我想使默认情况下在angular6中选中复选框,我在google中搜索并应用了很多解决方案
I want to make checkbox is checked by default in angular6 , i search in google and apply so many solution but it does not work.
推荐答案
<mat-checkbox class="example-margin" [(ngModel)]="myModel"/>
OR
<mat-checkbox [checked]="myModel" class="example-margin"/>
假定 myModel = true;
在 component.ts
在您的情况下,尝试初始化 this.languageObj.languageenabled = true
在 component.ts
In your case, try to init this.languageObj.languageenabled = true
in component.ts
这篇关于如何在角度6中选中默认复选框?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文