Concealed Dropdown Option

<div fxFlex="25" fxFlex.xs="100" class="px-8">
    <div class="form-label">Reporting Status <span class="reqSgnColor">*</span>
    </div>
    <mat-form-field appearance="outline">
        <mat-select matNativeControl required formControlName="reporting_status" filter="true" id="rep_status"
            name="rep_status" (valueChange)="update_reporting($event)">
            <mat-option *ngFor="let status of reporting_statuses" [value]="status.value">{{status.viewValue}}
            </mat-option>
        </mat-select>
        <mat-error> Select Reporting Status is Required</mat-error>
    </mat-form-field>
</div>

https://i.sstatic.net/zK7bq.png

Two distinct pages are involved here. One page requires a specific value to be hidden from the dropdown menu, while the other page needs that same value to be displayed in the dropdown. These two pages are "Issue-Tracker" and "Resolve-Issues". Both contain an edit button which serves the same purpose on both pages. When navigating to the "Issue-Tracker" page, the option "Resolved" should not appear in the dropdown, whereas when on the "Resolve-Issues" page, the option "Open" should not be included. However, when clicking the edit button, both pages lead to the "Edit Issue Page" where all options are available, as they remain static.

Answer №1

When transitioning to a different page, make sure to update the complnt_status array in order to fix any issues with dropdown options.

const index = complnt_status.findIndex((obj) => {
  return obj.viewValue === 'Close';
});

if (index !== -1) {
  complnt_status.splice(index, 1);
}

Answer №2

To simplify the process, you can establish two separate arrays for complnt_status in distinct ".ts" files:

For the Open Complaints component:

complnt_status: Complaintstatus[] = [ 
    {value: 1, viewvalue: 'Open'}, 
    {value: 2, viewvalue: 'Resolved'}, 
    {value: 4, viewvalue: 'Auto-Resolution'} 
]; 

And for the Resolve Complaints component:

complnt_status: Complaintstatus[] = [ 
    {value: 2, viewvalue: 'Resolved'}, 
    {value: 3, viewvalue: 'Close'}, 
    {value: 4, viewvalue: 'Auto-Resolution'} 
]; 

Similar questions

If you have not found the answer to your question or you are interested in this topic, then look at other similar questions below or use the search

Discover how to access all of the response headers from an HTTP request in Angular

Currently, I am utilizing HttpClient to make a request for a `json` file. My intention is to have the file cached using `ETag`, however, this feature does not seem to be functioning as expected. Upon investigation, it appears that the absence of sending of ...

Is a custom test required for PartiallyRequired<SomeType>?

Is there a way to create a function that validates specific fields as required on a particular type? The IFinancingModel includes the property statusDetails, which could potentially be undefined in a valid financing scenario, making the use of Required< ...

Encountering TypeScript 2 Compilation Issue with Angular 2 in VisualStudio 2015 Update 3

Encountering an error during the compilation of a TypeScript project that was functioning perfectly prior to upgrading to V2. I have transitioned from Typings to @Types and am only importing @Types/node in the project. Severity Code Description Proj ...

Unable to connect a unique FormGroup (using ControlValueAccessor) within a FormArray

We are working with two components, referred to as parent and child, both implementing ControlValueAccessor. The parent form is defined as follows: this.formBuilder.group({ children: this.formBuilder.array([]) }) While the child form looks like this: ...

Error TS2304: Unable to locate identifier 'RTCErrorEvent'

I am currently working on a WebRTC application using Quasar, typescript and Vue. In my code snippet below, I am encountering an issue where I don't get any errors in WebStorm (as it uses the project's eslint config), and I can navigate to the def ...

Monitoring internet navigation with Angular

I'm struggling to figure out how I can access the browsing history in Angular. In AngularJS, $location provided some functionality related to this, but in Angular, the Location service only offers forward and back methods without a way to view the ful ...

What is the process for uploading an array of files with AngularFire2 and Firebase Storage?

I encountered a dilemma trying to find answers to my question. Most resources, like the AngularFire2 documentation and an informative tutorial from angularfirebase.com, only demonstrate uploading one file at a time. As I aim to construct a photo gallery CM ...

Could someone provide a detailed explanation of exhaustMap in the context of Angular using rxjs?

import { HttpHandler, HttpInterceptor, HttpParams, HttpRequest, } from '@angular/common/http'; import { Injectable } from '@core/services/auth.service'; import { exhaustMap, take } from 'rxjs/operators'; import { Authe ...

Angular UI and Node backend causing CORS issues

Just diving into the world of node and could use a little assistance. Encountering this error message: Access to XMLHttpRequest at 'http://localhost:3000/api/auth/signin' from origin 'http://localhost:4200' has been blocked by CORS pol ...

Utilizing Angular 4 for secure authentication with PHP-JWT tokens

Embarking on my first web app project following an extensive Angular 4 course, I have opted to utilize wamp server for my backend database and JWT instead of traditional sessions. The initial step involved creating a login form using Reactive forms: < ...

Unable to refresh the current active route

After recently updating to the latest versions of RC3 and Router3alpha, I've noticed some changes. One major difference is that clicking on the link of an active route no longer triggers a component reload. How can I achieve this behavior with the up ...

Adjust the column width in Angular material tables

Is it possible to adjust the width of individual columns? I've attempted various methods, but it appears that the columns are consistently equal in width regardless of any styles applied. ...

After a loop, a TypeScript promise will be returned

I am facing a challenge in returning after all calls to an external service are completed. My current code processes through the for loop too quickly and returns prematurely. Using 'promise.all' is not an option here since I require values obtain ...

When utilizing an import statement in TypeScript, it is not possible to access ethers.js providers

While trying to utilize ethers.js provider in my TypeScript project using ts-node, I encountered the following issue: import { ethers } from "ethers"; const provider = new ethers.providers.JsonRpcProvider(url); The error message displayed was: ...

Developing a cutting-edge REST API with Node.js and TypeScript for the modern era in 202

Currently, I am tasked with creating a rest API using Node.JS and TypeScript. Initially, I considered using Express, but after looking into it further, it seems that Koa, Fastify, and Hapi may offer a more contemporary and efficient solution. With that in ...

Challenges with implementing Typescript in Next.js and the getStaticProps function

Having trouble with the implementation of getStaticProps where the result can be null or some data. The typings in getStaticProps are causing issues, even after trying conditional props. Any suggestions? type ProductType = { props: | { ...

Trouble with 'import type' declaration causing build issues in a Next.js project

Having trouble importing the Metadata type from the next module. The code snippet below is directly from the Next.js documentation. THE ISSUE client.js:1 ./app/layout.tsx:3:12 Syntax error: Unexpected token, expected "from" 1 | import React from 'r ...

ngDraggable does not function properly when the dropzone is larger and includes a scrollbar on the body

Here is a demo showing the issue: The current version 0.1.11 does not support drag and drop functionality. This is how I have implemented the code: <uib-accordion-group is-open="category.open" name="category-{ ...

What steps can I take to address the issue of missing modules in an Angular application?

I am facing an issue with my Angular application where I am using two local libraries. Despite having all dependencies declared and imported correctly, the build process continues to throw errors related to missing modules. To give you a better picture of ...

Angular validation is malfunctioning for fields that have names ending with periods

Currently in the process of generating dynamic input fields <input class="form-control-lg form-control" placeholder="{{data.DisplayName}}" formControlName="{{data.labelName}}" type="text" maxlength="13" ...