im trying to set two variables at once using a dialog popup but for some reason, it only shows the playerRequested variable but not the activity variable. here it my html code
<body>
<h1>Create A Team</h1>
<p>Players Needed</p>
<input matInput type="number" min="1" max="4" [(ngModel)]="data.requestedPlayers">
<p>Activity</p>
<mat-button-toggle-group #togglegroup = "matButtonToggleGroup" [(ngModel)]="data.activity">
<mat-button-toggle value="Unrated">Unrated</mat-button-toggle>
<mat-button-toggle value="Competitive">Competitive</mat-button-toggle>
</mat-button-toggle-group>
{{togglegroup.value}}
<button mat-raised-button [mat-dialog-close]="data.activity" [mat-dialog-close]="data.requestedPlayers" cdkFocusInitial>Post</button>
</body>
and here is my .ts file
import { Component, Inject } from '@angular/core';
import {MatDialog, MatDialogRef, MAT_DIALOG_DATA, MatDialogClose, MatDialogConfig} from '@angular/material/dialog';
export interface DialogData {
requestedPlayers: string;
activity: string;
}
@Component({
selector: 'app-root',
templateUrl: './app.component.html',
styleUrls: ['./app.component.scss']
})
export class AppComponent {
title = 'val-app';
requestedPlayers : string;
activity : string;
constructor(public dialog: MatDialog) {}
openDialog(){
const dialogConfig = new MatDialogConfig();
let dialogRef = this.dialog.open(CreateTeamOptions, {
height: '326px',
width: '237px',
data: {requestedPlayers: this.requestedPlayers, activity: this.activity}
});
dialogRef.afterClosed().subscribe(result =>{
console.log('Dialog result is: '+ result.activity);
this.requestedPlayers = result;
this.activity = result;
});
}
}
@Component({
selector: 'create-team-options',
templateUrl: 'create-team-options.html',
styleUrls: ['./create-team-options.scss']
})
export class CreateTeamOptions {
constructor(
public dialogRef: MatDialogRef<CreateTeamOptions>,
@Inject(MAT_DIALOG_DATA) public data: DialogData) {}
onNoClick(): void {
this.dialogRef.close();
}
}
on the open dialog it should save both variables from the html file where they were set but for some reason it doesnt.
if you lads could help that would be much appreciated!! thanks
Edited: just tried switching which one it sets first for the post button on html and it sets the first one to both but not sure how to set them differently