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

相关内容

热门资讯

科技揭秘!hhpoker德州有... 科技揭秘!hhpoker德州有挂吗,wepoker辅助透视,真是真的有挂(确实有挂)wepoker辅...
9分钟了解!pokemmo脚本... 9分钟了解!pokemmo脚本辅助器,hh poker辅助器先试用,一直真的有挂(有挂助手)1、首先...
科技分享!uupoker有透视... 科技分享!uupoker有透视吗,aapoker透视脚本入口,好像存在有挂(有挂存在)科技分享!uu...
一分钟揭秘!微扑克游戏辅助器,... 一分钟揭秘!微扑克游戏辅助器,德普之星辅助器app,切实真的有挂(有挂总结)1、用户打开应用后不用登...
三分钟了解!wepoker有透... 三分钟了解!wepoker有透视功能吗,aapoker怎么控制牌,原来是有挂(真实有挂)1、辅助器安...
总算了解!pokemmo手机版... 总算了解!pokemmo手机版修改器,wepoker怎么挂飞机,其实真的是有挂(有挂秘诀)1、模拟器...
科普攻略!菠萝德州透视脚本,w... 科普攻略!菠萝德州透视脚本,wepoker破解游戏盒子,一贯有挂(有挂透明挂)1、首先打开辅助器下载...
分辨真假!xpoker辅助器,... 分辨真假!xpoker辅助器,aapoker透视插件,切实真的有挂(有挂规律)在进入软件靠谱后,参与...
终于清楚!约局吧德州真的存在透... 终于清楚!约局吧德州真的存在透视吗,aapoker真的假的,真是是真的有挂(有挂方针)该软件可以轻松...
一分钟揭秘!wepoker私人... 一分钟揭秘!wepoker私人局透视插件,德普之星透视软件免费入口官网,竟然真的有挂(有挂秘籍)1、...