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

相关内容

热门资讯

透视免费!菠萝辅助器免费版的功... 透视免费!菠萝辅助器免费版的功能介绍,steampokermaster辅助,指引教程(有挂攻略)-哔...
辅助透视!佛手在线大菠萝智能辅... 辅助透视!佛手在线大菠萝智能辅助器,wepoker私人局开挂视频,秘籍教程(有挂规律)-哔哩哔哩1、...
透视黑科技!we poker游... 透视黑科技!we poker游戏下,hhpoker德州机器人,步骤教程(确实有挂)-哔哩哔哩在进入h...
透视私人局!pokemmo脚本... 透视私人局!pokemmo脚本辅助下载,wepoker可以开透视吗,教程书教程(确实有挂)-哔哩哔哩...
透视ai代打!hhpoker有... 透视ai代打!hhpoker有辅助吗,wpk透视插件,要领教程(有挂技巧)-哔哩哔哩进入游戏-大厅左...
透视规律!hhpoker视频巡... 透视规律!hhpoker视频巡查真的假的,wpk有那种辅助吗,绝活教程(有挂实锤)-哔哩哔哩1、下载...
透视安卓版!pokeplus脚... 透视安卓版!pokeplus脚本,wpk俱乐部辅助器,手段教程(讲解有挂)-哔哩哔哩1、起透看视 w...
透视私人局!智星德州插件怎么下... 透视私人局!智星德州插件怎么下载,wepoker软件辅助程序,大纲教程(真实有挂)-哔哩哔哩1、用户...
透视科技!pokemmo脚本手... 透视科技!pokemmo脚本手机版,werplan有挂吗,操作教程(详细教程)-哔哩哔哩1、进入游戏...
透视软件!wepoker透视最... 透视软件!wepoker透视最简单三个步骤,pokemmo辅助器脚本下载,阶段教程(揭秘有挂)-哔哩...