我从角度材质的mat-checkbox出现问题。我已经给该复选框的ID是这样的:角度mat-checkbox getElementById
<mat-checkbox class="toolbar-checkbox" id="myCheckbox">
MyCheckbox
</mat-checkbox>
之后,我想的东西与此元素是这样的:
(<MatCheckbox>document.getElementById('myCheckbox')).checked = true;
但unfortunally我得到这个错误:
TS2352: Type 'HTMLElement' cannot be converted to type 'MatCheckbox'.
Property '_changeDetectorRef' is missing in type 'HTMLElement'.
(<MatCheckbox>document.getElementById('asdasd')).checked = true;
我该如何解决这个问题,或者是否有更好的方法来使用复选框而不使用[(ngModel)]?
主席先生,让我高兴 - 你打败了我! – rinukkusu
Danke Schon @rinukkusu \ o / – Faisal