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);  // 初始选择
    });
  }
}

相关内容

热门资讯

透视免费!wepoker透视脚... 1、透视免费!wepoker透视脚本下载,新超凡软件辅助,解密教程(有挂技巧);详细教程。2、wep...
透视插件!wpk透视脚本,边锋... 透视插件!wpk透视脚本,边锋微信小程序,新2025教程(有挂方法);亲真的是有正版授权,小编(透视...
透视安卓版!wepoker辅助... 透视安卓版!wepoker辅助器怎么用,禅游指尖四川无限钻石,技巧教程(有挂辅助);亲真的是有正版授...
透视私人局!wepoker透视... 透视私人局!wepoker透视脚本苹果,四川熊猫辅助器,透明挂教程(有挂技巧);《WPK辅助透视》‌...
透视透视!德朴之星脚本,闲来山... 透视透视!德朴之星脚本,闲来山水广西辅助,细节方法(有挂神器);建议优先通过闲来山水广西辅助透明挂内...
透视线上!aapoker辅助工... 1、透视线上!aapoker辅助工具免费下载,新超凡软甲辅助,插件教程(有挂神器)。2、新超凡软甲辅...
透视ai!智星德州有脚本吗,约... 透视ai!智星德州有脚本吗,约战竞技场辅助器,透牌教程(有挂软件);人气非常高,ai更新快且高清可以...
透视好友房!aapoker辅助... 透视好友房!aapoker辅助插件工具,新玄龙开挂图片,2025版教程(有挂技巧)1、不需要AI权限...
透视辅助!wepoker底牌透... 1、透视辅助!wepoker底牌透视脚本下载,小程序牵手跑得快辅助器,教你攻略(有挂神器)。2、小程...
透视软件!aapoker辅助包... 透视软件!aapoker辅助包,创思维app有挂吗,揭秘教程(有挂方法)1、玩家可以在创思维app有...