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

相关内容

热门资讯

教你透视!pokermaste... 教你透视!pokermaster修改器!真是有辅助插件(有人有挂)-哔哩哔哩1、进入游戏-大厅左侧-...
有挂透视!wepoker有透视... 有挂透视!wepoker有透视吗,wepoker俱乐部辅助,大纲教程(今日头条)-哔哩哔哩1、起透看...
总结透视!wepoker透视脚... 总结透视!wepoker透视脚本免费下载pc,epoker透视底牌,机巧教程(真是有挂)-哔哩哔哩1...
揭露透视!werplan免费挂... 揭露透视!werplan免费挂下载!一直真的有辅助技巧(有挂详细)-哔哩哔哩1、玩家可以在werpl...
教你透视!werplan怎么透... 教你透视!werplan怎么透视,wepoker免费脚本咨询,手册教程(真实有挂)-哔哩哔哩1、让任...
了解透视!来玩app破解版!果... 了解透视!来玩app破解版!果然是真的有辅助技巧(有挂方式)-哔哩哔哩运来玩app破解版辅助工具,进...
推荐透视!wepoker到底有... 推荐透视!wepoker到底有没有透视,aapoker透视脚本入口,方案教程(有挂工具)-哔哩哔哩w...
了解透视!哈糖大菠萝软件下载!... 了解透视!哈糖大菠萝软件下载!总是真的有辅助神器(有人有挂)-哔哩哔哩1、打开软件启动之后找到中间准...
必备透视!hhpoker怎么防... 必备透视!hhpoker怎么防作必弊,aa poker透视软件,演示教程(有挂功能)-哔哩哔哩1、h...
曝光透视!werplan辅助软... 曝光透视!werplan辅助软件!竟然真的有辅助方法(有挂透明挂)-哔哩哔哩1、下载好werplan...