admin管理员组文章数量:1399901
We can make the input field as read only mode using the [readonly]="true"
directives, in the same is it possible to make the mat-toggle-group as readonly mode,
<mat-button-toggle-group name="fontStyle" aria-label="Font Style" [readonly]="true">
<mat-button-toggle value="bold">Bold</mat-button-toggle>
<mat-button-toggle value="italic">Italic</mat-button-toggle>
<mat-button-toggle value="underline">Underline</mat-button-toggle>
</mat-button-toggle-group>
I don't want to make it as disabled. If it is disabled during the form submission I can't access this value. Readonly means user don't change the value if it is already set.
We can make the input field as read only mode using the [readonly]="true"
directives, in the same is it possible to make the mat-toggle-group as readonly mode,
<mat-button-toggle-group name="fontStyle" aria-label="Font Style" [readonly]="true">
<mat-button-toggle value="bold">Bold</mat-button-toggle>
<mat-button-toggle value="italic">Italic</mat-button-toggle>
<mat-button-toggle value="underline">Underline</mat-button-toggle>
</mat-button-toggle-group>
I don't want to make it as disabled. If it is disabled during the form submission I can't access this value. Readonly means user don't change the value if it is already set.
Share Improve this question edited Nov 23, 2020 at 20:35 marc_s 756k184 gold badges1.4k silver badges1.5k bronze badges asked Nov 19, 2020 at 12:48 RijoRijo 3,0436 gold badges39 silver badges67 bronze badges2 Answers
Reset to default 5Well I'm not sure if even the disabled attribute will work. Angular team doesn't seem to care as it's not a native element like button or input so browser doesn't understand it. see this
Only solution I can think of is using css, add a conditional style, setting pointer-events: none
on the mat-button-toggle-group and pointer-events: auto;
to re-enable it, which will make it unclickable but still retaining its properties and value. This will require some additional highlight though for user to understand that its set to readonly.
Note that some old browsers and IE10 and below does not support this.
Disabled
attribute is working.
stackblitz
本文标签: javascriptHow to make matbuttontogglegroup as read only modeStack Overflow
版权声明:本文标题:javascript - How to make mat-button-toggle-group as read only mode - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1744243835a2596913.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论