如何在切换组中设置默认 Select 的最后一个按钮.
这是我的密码.

<mat-button-toggle-group #group="matButtonToggleGroup">
    <mat-button-toggle value="Heritage">
        <span>Heritage</span>
    </mat-button-toggle>
    <mat-button-toggle value="Nature">
        <span>Nature</span>
    </mat-button-toggle>
    <mat-button-toggle value="People">
        <span>People</span>
    </mat-button-toggle>
    <mat-button-toggle value="All">
        <span>All</span>
    </mat-button-toggle>
</mat-button-toggle-group>

推荐答案

我把它修好了.只需将value属性添加到mat-button-toggle-group标记即可.

<mat-button-toggle-group #group="matButtonToggleGroup" value="All">
<mat-button-toggle value="Heritage">
    <span>Heritage</span>
</mat-button-toggle>
<mat-button-toggle value="Nature">
    <span>Nature</span>
</mat-button-toggle>
<mat-button-toggle value="People">
    <span>People</span>
</mat-button-toggle>
<mat-button-toggle value="All">
    <span>All</span>
</mat-button-toggle>

Angular相关问答推荐

如何取消针叶林输入的自动填充?

日语字符不受角形约束控制

使用当前选定的选项创建IF语句

带有服务依赖的Angular测试类

是否可以将Angular 路由配置为在点击带有本地人力资源S的锚点时更新Angular 路由?

Angular 15:将数据从主零部件传递到辅零部件

Angular 17:在MouseOver事件上 Select 子组件的正确ElementRef

如何确保[共享]组件是真正的哑组件?(Angular )

从Angular 前端访问ASP.NET Core 8 Web API时出现CORS错误

角路径S异步旋转变压器仍可观察到

我需要取消订阅路由的可观察事件吗

Angular *ngIf 表达式中这么多冒号的作用是什么?

URL 更改但组件未在 Angular 导航中呈现

Cypress 12.8.1 无法使用条纹元素 iframe

Angular14:支持旧版浏览器的官方方式是什么?

RxJS 基于先前的数据响应执行请求(涉及循环对象数组)

Angular 项目构建仅在 GitHub Actions 上失败

如何手动延迟加载模块?

将 Angular 5 升级到 6 时,我得到不兼容的对等依赖(使用 ng update @angular/core)

Failed to execute 'setAttribute' on 'Element': ']' is not a valid attribute name