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怎么下载游戏(透视)一贯真的是有辅助透视(哔哩哔哩)1)wepoker怎...
第六分钟法门!werplan怎... 第六分钟法门!werplan怎么作必弊(透视)真是有辅助脚本(哔哩哔哩)一、werplan怎么作必弊...
第9分钟技法!epoker透视... 第9分钟技法!epoker透视底牌(透视)本来是真的有辅助安装(哔哩哔哩)1、操作简单,无需epok...
第3分钟秘籍!wepoker轻... 第3分钟秘籍!wepoker轻量版透视方法(透视)真是是有辅助辅助(哔哩哔哩)1、wepoker轻量...
第9分钟指引!wepoker透... 第9分钟指引!wepoker透视app下载(透视)确实是真的有辅助工具(哔哩哔哩)1、每一步都需要思...
三分钟积累!poker mas... 三分钟积累!poker master辅助(透视)一贯存在有辅助插件(哔哩哔哩)1、poker mas...
六分钟教程书!hhpoker外... 六分钟教程书!hhpoker外开挂靠谱吗(透视)真是真的是有辅助透视(哔哩哔哩)1、每一步都需要思考...
2分钟诀窍!wepoker可以... 2分钟诀窍!wepoker可以开透视吗(透视)一直存在有辅助插件(哔哩哔哩)1、wepoker可以开...
九分钟妙计!wepoker黑侠... 九分钟妙计!wepoker黑侠辅助器(透视)一直是有辅助透视(哔哩哔哩)1、下载好wepoker黑侠...
第6分钟要领!wepokerp... 第6分钟要领!wepokerplus作必弊(透视)一直存在有辅助教程(哔哩哔哩)所有人都在同一条线上...