<div fxFlex="25" fxFlex.xs="100" >
<div >Ticket Status <span >*</span>
</div>
<mat-form-field appearance="outline">
<mat-select matNativeControl required formControlName="complaint_status" filter="true" id="comp_status" name="comp_status" (valueChange)="closed_over_by($event)">
<mat-option *ngFor="let status of complnt_status" [value]="status.value">{{status.viewValue}}
</mat-option>
</mat-select>
<mat-error> Select Status is Required</mat-error>
</mat-form-field>
</div>
Basically I have 2 pages, in one page i need to hide a value from dropdown, and show the same value in other Page of the the dropdown. actually i have two pages "Open-Complain" and another is "Resolve-Complaints" so in that i have a button called edit button (Present on both pages Identical).When i go on Page "Open-Complants" in Drop down "Close Option" shoulnt appear and in Case of "Resolve-Complaints" in drop down "open option shouldnt be there".on NOte When Click Edit Button Both Comes On "Edit Complaint Page only".option are static.
CodePudding user response:
On event when changing route to the other page, modify the array complnt_status that would solve the problem for drop down options.
const indexOfObject = complnt_status.findIndex((object) => {
return object.viewValue === 'Close';
});
if (indexOfObject !== -1) {
complnt_status.splice(indexOfObject, 1);
}
CodePudding user response:
An easy and quick solution is to create two complnt_status arrays in the two different ".ts" files, i.e.
For Open Complaints component use
complnt_status: Complaintstatus[] = [
{value: 1, viewvalue: 'Open'},
{value: 2, viewvalue: 'Resolved'},
{value: 4, viewvalue: 'Auto-Resolution'}
];
And for Resolve Complaints component use
complnt_status: Complaintstatus[] = [
{value: 2, viewvalue: 'Resolved'},
{value: 3, viewvalue: 'Close'},
{value: 4, viewvalue: 'Auto-Resolution'}
];