I am seeking information on how to access the values of selected items in templates. Specifically, I want to understand how to retrieve the selected value of IPMIDisplayTime
and IPMIDisplayTime
within the template for later use.
import {ViewChild, ElementRef} from '@angular/core';
@Component({
selector: 'app-select-dialog',
template:`<h1 mat-dialog-title>
{{ title | translate }}
</h1>
<div mat-dialog-content>
<mat-select #IPMIDisplayTime name="name" placeholder="optionPlaceHolder" [(ngModel)]="IPMIDisplayTimeSelection">
<mat-option *ngFor="let option of options" [value]="options.value">
{{ option.label }}
</mat-option>
</mat-select>
</div>
<div mat-dialog-actions>
<span fxFlex></span>
<button class="mat-raised-button mat-accent" (click)="dialogRef.close(false)">{{"Close" | translate}}</button>
<span fxFlex></span>
<button class="mat-raised-button mat-accent" (click)="dialogRef.close(true)">{{"OK" | translate}}</button>
</div>`,
styleUrls : [ './select-dialog.component.scss' ]
})
export class SelectDialogComponent {
public title: string;
public options: Array<{ label: string, value: string }>;
public optionPlaceHolder: string;
public method: string;
public params: string;
@ViewChild('IPMIDisplayTime') IPMIDisplayTimeSelect: ElementRef;
IPMIDisplayTimeSelection: string;
constructor(public dialogRef: MatDialogRef < SelectDialogComponent >, protected translate: TranslateService ) {
}
}