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

相关内容

热门资讯

脚本开挂!wpk刷入池率脚本,... 脚本开挂!wpk刷入池率脚本,wpk透视工作室(透视)真是存在有技巧(哔哩哔哩)1、下载好脚本下载之...
昨日!newpoker脚本,微... 昨日!newpoker脚本,微信小程序微乐辅助器教程图片,关于脚本(有挂规律)-哔哩哔哩1、玩家可以...
脚本了解!aapoker免费透... 脚本了解!aapoker免费透视脚本,aapoker辅助工具安全吗(透视)都是真的是有神器(哔哩哔哩...
透视讲解!hhpoker真的假... 透视讲解!hhpoker真的假的,微信微乐小程序有窍门吗,总结透视(发现有挂)-哔哩哔哩1、任何hh...
透视揭露!hhpoker德州挂... 透视揭露!hhpoker德州挂真的有吗,hhpoker辅助软件下载(透视)其实是真的器(哔哩哔哩)脚...
透视挂!wepoker怎么发冤... 透视挂!wepoker怎么发冤家牌,微乐兰州麻将小程序辅助,推荐脚本(有挂技巧)-哔哩哔哩1、wep...
脚本分享!hhpoker免费透... 您好,这款游戏可以开挂的,确实是有挂的,需要了解加去威信【136704302】很多玩家在这款游戏中打...
今天下午!wepoker手机版... 今天下午!wepoker手机版透视脚本,手机微乐小程序破解器如何使用,关于脚本(有挂分析)-哔哩哔哩...
脚本详细!德普之星透视辅助插件... 脚本详细!德普之星透视辅助插件,德普辅助器怎么用(透视)切实是真的工具(哔哩哔哩)1、免费脚本咨询教...
最终!竞技联盟透视插件,微乐辅... 最终!竞技联盟透视插件,微乐辅助脚本,开挂透视(真是有挂)-哔哩哔哩1、下载好竞技联盟透视插件脚本下...