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

相关内容

热门资讯

玩家必备教程!德普辅助软件(辅... 玩家必备教程!德普辅助软件(辅助挂)竟然是真的有挂(有挂攻略)1、每一步都需要思考,不同水平的挑战会...
揭秘一下!wepoker辅助器... 揭秘一下!wepoker辅助器最新版本更新内容(辅助挂)一贯是有挂(揭秘有挂)1、wepoker辅助...
热点推荐!德州局怎么透视(辅助... 热点推荐!德州局怎么透视(辅助挂)切实是真的有挂(有挂秘笈)1、点击下载安装,德州局怎么透视脚本分类...
玩家科普!pokemmo内置修... 玩家科普!pokemmo内置修改器(辅助挂)一贯存在有挂(有人有挂)1、下载好pokemmo内置修改...
最新研发!约局吧能不能开挂(辅... 最新研发!约局吧能不能开挂(辅助挂)切实有挂(有挂规律)1、下载好约局吧能不能开挂脚本下载之后点击打...
最新技巧!we poker辅助... 最新技巧!we poker辅助器(辅助挂)切实是有挂(有挂实锤)1、每一步都需要思考,不同水平的挑战...
记者发布!wepoker挂(辅... 记者发布!wepoker挂(辅助挂)原来存在有挂(详细教程)1、起透看视 wepoker挂辅助软件价...
玩家科普!hhpoker是内部... 玩家科普!hhpoker是内部控制吗(辅助挂)本来真的是有挂(有挂方法)1、hhpoker是内部控制...
科普常识!wepoker软件靠... 科普常识!wepoker软件靠谱么(辅助挂)确实有挂(有挂规律)1、wepoker软件靠谱么免费辅助...
总算明白!智星菠萝透视(辅助挂... 总算明白!智星菠萝透视(辅助挂)好像真的有挂(有挂秘笈)1、超多福利:超高返利,海量正版游戏,智星菠...