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

相关内容

热门资讯

透视策略!wepoker辅助脚... 透视策略!wepoker辅助脚本(AApoker透视)好像有辅助攻略(哔哩哔哩)1、该软件可以轻松地...
透视绝活儿!wepoker透视... 透视绝活儿!wepoker透视脚本免费(HHpoker后台)都是有辅助插件(哔哩哔哩)1、金币登录送...
透视法子!wepoker底牌透... 透视法子!wepoker底牌透视脚本(HHpoker辅助)总是是有辅助app(哔哩哔哩)1、金币登录...
透视练习!aapoker脚本怎... 透视练习!aapoker脚本怎么用(HHpoker安装包)好像有辅助方法(哔哩哔哩)aapoker脚...
透视手段!wepoker私人局... 透视手段!wepoker私人局开挂视频(WePoKer牌型)其实存在有辅助插件(哔哩哔哩)1、让任何...
透视模块!wepoker黑侠破... 透视模块!wepoker黑侠破解(WePoKer设置)切实真的是有辅助攻略(哔哩哔哩)透视模块!we...
透视阶段!wepoker透视脚... 透视阶段!wepoker透视脚本下载(WePoKer私人局)一直有辅助工具(哔哩哔哩)1、下载好we...
透视妙计!佛手在线大菠萝辅助(... 透视妙计!佛手在线大菠萝辅助(HHpoker控制牌)总是存在有辅助脚本(哔哩哔哩)该软件可以轻松地帮...
透视窍要!epoker透视(H... 透视窍要!epoker透视(HHpoker功能)果然是有辅助方法(哔哩哔哩)1、每一步都需要思考,不...
透视技法!wepoker轻量版... 透视技法!wepoker轻量版透视方法(WePoKer祈福)总是真的是有辅助软件(哔哩哔哩)1、在w...