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

相关内容

热门资讯

透视有挂"epoke... 透视有挂"epoker透视"本来是有辅助插件(哔哩哔哩)1、epoker透视免费脚本咨询教程、epo...
透视了解"wepok... 透视了解"wepoker怎么破解游戏"本来存在有辅助技巧(哔哩哔哩)进入游戏-大厅左侧-新手福利-激...
透视教你"werpl... 透视教你"werplan怎么作必弊"一直是真的辅助攻略(哔哩哔哩)1)werplan怎么作必弊免费钻...
透视详细"wepok... 透视详细"wepoker辅助插件功能"一贯存在有辅助挂(哔哩哔哩)1、首先打开wepoker辅助插件...
透视辅助"aapok... 透视辅助"aapoker怎么开辅助器"原来存在有辅助软件(哔哩哔哩)aapoker怎么开辅助器脚本下...
透视透视"来玩app... 透视透视"来玩app 德州 辅助"好像是真的辅助技巧(哔哩哔哩)1、每一步都需要思考,不同水平的挑战...
透视专业"aapok... 透视专业"aapoker透视怎么用"真是是有辅助插件(哔哩哔哩)1、aapoker透视怎么用免费脚本...
透视推荐"fishp... 透视推荐"fishpoker透视"一贯有辅助脚本(哔哩哔哩)1、fishpoker透视有没有辅助教程...
透视教你"aapok... 透视教你"aapoker真的假的"本来真的有辅助方法(哔哩哔哩)1、打开软件启动之后找到中间准星的标...
透视解密"约局吧德州... 透视解密"约局吧德州透视"一直有辅助技巧(哔哩哔哩)1)约局吧德州透视有没有挂:进一步探索约局吧德州...