小编Tar*_*are的帖子

为什么没有数据源的 <mat-table> 没有显示在 Angular 7 中

我想使用 a<mat-table>来显示选项的名称及其对应的给定值(供用户更改)。由于选项可能需要通过不同方式(例如滑动切换或垫子选择)设置其值,因此我必须在没有数据源的情况下将其写下来(或者至少据我所知,不能在打字稿文件中使用预先编写的 html 标签)。

因此,我的 MWE 将是这样的:

<mat-table>
    <mat-header-row *matHeaderRowDef>
        <mat-header-cell>header</mat-header-cell>
    </mat-header-row>

    <mat-row>
        <mat-cell>
             cell
        </mat-cell>
    </mat-row>
</mat-table>
Run Code Online (Sandbox Code Playgroud)

但是,当我查看我的页面时,它只显示一行没有任何字符串。我想在一个<mat-card>(或者更确切地说<mat-card-content>)内使用这个表,但即使我在它之外尝试它,我也只是得到了这条线而没有别的。这是垫卡中的样子:

空行

如何正确显示表格?


*编辑:* 因为它被要求,这里也是.ts文件。

import { Component, OnInit, ViewChild } from '@angular/core';

@Component({
  selector: 'app-general',
  templateUrl: './general.component.html',
  styleUrls: ['./general.component.scss']
})
export class GeneralComponent implements OnInit {


  @ViewChild('resolutionSelect') resolutionSelect: MatSelect;

  resolutions: ResolutionOptionsInterface[] = [
    { value: '1920 x 1080' },
    { value: '800 x 600' }
  ];
  public selectedRes = this.resolutions[0];
  public isFullscreenEnabled = true;

  constructor() { …
Run Code Online (Sandbox Code Playgroud)

angular-material angular mat-table

6
推荐指数
1
解决办法
9356
查看次数

如何在C++中仅将成员变量转换为字节数组?

长话短说

我有一个不仅仅是成员变量(例如它们包含函数)的结构,我只想将成员变量转换为字节数组(/向量),这样我就可以将数据上传到Vulkan中的显卡。如何仅获取结构体中代表成员变量的部分?

我的具体做法

我有一个设置,我使用一个空ParamsBase结构,并从中继承ParamsAParamsB...实际包含成员变量的结构。我使用它,这样我就可以将成员保留ParamsBase在一个Container类中,而无需实际了解具体实现。

我想将类中的 Params 实例转换Container为字节缓冲区。

ParamsA由于我需要实际/ /... 结构的大小ParamsB,因此在创建实例时我使用了一个通用子类,该子类允许我使用单个getSize()函数,而不是在每个 substruct 中覆盖它

// =============================
// === Define Params structs ===
// =============================
struct ParamsBase
{
    virtual size_t getSize() const noexcept = 0;
};

struct ParamsA : public ParamsBase
{
    float vec[3] = { 2.3f, 3.4f, 4.5f };
};

// ===============================================================
// === enable sizeof query for derived structs from ParamsBase === …
Run Code Online (Sandbox Code Playgroud)

c++ struct sizeof

6
推荐指数
1
解决办法
375
查看次数

如何获取特定组件(例如按钮悬停背景)的当前角度主题颜色?

我想在我用 Angular 7 和材料设计显示的列表上有一个悬停颜色。由于$primary,$accent$warn颜色不能很好地用于此目的,因此我想获得与悬停时按钮具有的悬停颜色相同的颜色。我目前正在使用material design multiple-themes example 中的 candy-app-theme 和 dark-theme ,所以我没有自己定义这种颜色。

但是,为了定义我的悬停颜色,我需要查询此按钮悬停颜色。因此:如何查询此颜色?

@mixin options-component-theme($theme) {
    $primary: map-get($theme, primary);
    $accent: map-get($theme, accent);// Use mat-color to extract individual colors from a palette as necessary.

    //i have tried these two:
    $hover: map-get($theme, hover);
    $focused-button: map-get($theme, focused-button);

    $primary-color: mat-color($primary);
    $accent-color: mat-color($accent);

    .listItemFormat:hover {
    background-color: $focused-button;
Run Code Online (Sandbox Code Playgroud)

}

我试图通过hoverand获取颜色focused-button如 TimTheEnchanter 在这个答案中列出的那样,但是这不起作用(我最终没有任何可见的悬停效果)。

angular scss-mixins angular-material-7

1
推荐指数
1
解决办法
1859
查看次数