【问题标题】:Angular - How to get selected cell value from mat tableAngular - 如何从垫表中获取选定的单元格值
【发布时间】:2021-06-03 01:52:03
【问题描述】:

如何从 mat 表的选定单元格中获取值。我附上了一个示例代码,可以在其中获取行和索引。但我想要所选单元格中的值。

我在stackblitz 附上了一个示例代码,并在图片中添加了所需的格式 下面,

required format

【问题讨论】:

    标签: angular angular-material angular-material-table


    【解决方案1】:

    如果您只想获取所选列的值,您可以将cell 设为 HTMLElement 并从中获取文本。您可以在代码中添加:

    select(event: MouseEvent, cell: HTMLElement) {
        
         const value = cell.textContent;
         console.log(cell.textContent);
         
         .....
         .....
    

    【讨论】:

    • 这有帮助吗?
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2012-07-27
    • 1970-01-01
    • 2013-08-09
    • 1970-01-01
    • 1970-01-01
    • 2020-11-01
    • 1970-01-01
    相关资源
    最近更新 更多