AngularMaterial组件列表未报告初始选择
创始人
2024-10-28 12:00:52
0

在 Angular Material 组件列表中,发现在早期版本中初始化时的选择不会被报告。这可能会给开发人员带来困扰,然而,这个问题已经在后来的版本中得到了修复。

解决方法可以是升级版本,或者在代码中加入“ngAfterViewInit”来设置初始选择。下面是代码示例:

import { Component, ViewChild, AfterViewInit } from '@angular/core';
import { MatSelectionList } from '@angular/material/list';

@Component({
  selector: 'app-your-component',
  templateUrl: './your-component.component.html',
  styleUrls: ['./your-component.component.scss']
})
export class YourComponentComponent implements AfterViewInit {
  @ViewChild(MatSelectionList) selectionList: MatSelectionList;

  ngAfterViewInit(): void {
    this.selectionList.selectedOptions.selected.forEach(item => {
      console.log(item.value);  // 初始选择
    });
  }
}

相关内容

热门资讯

重大来袭!we poker辅助... 这是一款非常优秀的aapoker透视脚本入口 ia辅助检测软件,能够让你了解到aapoker透视脚本...
1.9分钟了解!wepoker... 此外,数据分析德州(wepoker永久免费脚本)辅助神器app还具备辅助透视行为开挂功能,通过对客户...
揭秘!hhpoker免费透视脚... 揭秘!hhpoker免费透视脚本,pokermaster脚本,安装教程(有挂神器)1、点击下载安装,...
总算了解!德普之星透视辅助软件... 总算了解!德普之星透视辅助软件激活码,德普之星有透视辅助吗,2025教程(有挂技巧);亲真的是有正版...
发现一款!htx矩阵wepok... 发现一款!htx矩阵wepoker辅助,epoker透视底牌,2025新版(有挂攻略);htx矩阵w...
科技分享!pokemmo手机版... 科技分享!pokemmo手机版透视脚本,wpk辅助器,透视教程(有挂攻略)1、点击下载安装,微扑克w...
总算了解!hhpoker透视工... 总算了解!hhpoker透视工具,wepoker代打辅助,科技教程(有挂透明)1、不需要AI权限,帮...
发现一款!wepoker透视苹... 1、发现一款!wepoker透视苹果系统,约局吧开挂神器是真的吗,系统教程(有挂辅助);详细教程。2...
玩家必看教程!htx矩阵wep... 玩家必看教程!htx矩阵wepoker辅助,epoker透视,靠谱教程(有挂技巧);人气非常高,ai...
让我来分享经验!悦扑克脚本,a... 让我来分享经验!悦扑克脚本,aapoker插件,科技教程(有挂神器);玩家必备必赢加哟《136704...