【发布时间】:2020-11-09 17:14:45
【问题描述】:
现在我遇到了枚举问题。 我想在具有枚举值的组件中进行 mat-select,但我不明白,这怎么可能。 我试过了,但没有任何效果
我的ts组件代码
import { Component, OnInit } from '@angular/core';
import { FormControl, FormGroup } from '@angular/forms';
import { select, Store } from '@ngrx/store';
import { Currency } from 'src/app/enums/CurrencyType';
import { Edition } from 'src/app/enums/EditionType';
import { Author } from 'src/app/models/Author';
import { getAuthorsList } from 'src/app/store/author/author.actions';
import { getAuthorsSelector } from 'src/app/store/author/author.selector';
@Component({
selector: 'app-printing-edition-item',
templateUrl: './printing-edition-item.component.html',
styleUrls: ['./printing-edition-item.component.css']
})
export class PrintingEditionItemComponent implements OnInit {
type: Edition -- my enum
constructor(private store: Store) {
}
}
我的枚举
export enum Edition{
None = 0,
Journal = 1,
Newspaper = 2,
Book = 3
}
我在 HTML 中的尝试:
<mat-form-field>
<mat-label>Category</mat-label>
<mat-select formControlName="type">
<mat-option *ngFor="let item of type" value="item">type[item]</mat-option>
</mat-select>
</mat-form-field>
【问题讨论】:
标签: angular enums angular-material-7