Analyze the entered text against the available choices in the combo box

I am working on a combo box that allows users to enter text. My goal is to display a warning message when the user types something that does not match any of the options in the combo box selection. Below is the code for my combo box:

<mat-form-field appearance="outline" class="width-1">
     <mat-label>Aircraft Type (ICAO)</mat-label>
                <!-- test autocomplete aircraft type -->
                <input
                  type="text"
                  placeholder="Aircraft Type (ICAO)"
                  aria-label="Aircraft Type (ICAO)"
                  matInput
                  formControlName="aircraftType"
                  [matAutocomplete]="type"
                  (input)="onAircraftTypeChange()"
                />
                <span matSuffix class="down">
                  <mat-icon>arrow_drop_down</mat-icon>
                </span>
                <mat-autocomplete
                  #type="matAutocomplete"
                  (optionSelected)="onSelectAircraftType($event.option.value)"
                  [displayWith]="displayAircraftTypeFn"
                >
                  <mat-option
                    *ngFor="let type of filteredAircraftTypes | async"
                    [value]="type"
                  >
                    {{ type.label }}
                  </mat-option>
                </mat-autocomplete>
                <!-- end test autocomplete -->
              </mat-form-field>

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

Answer №1

          <input
              type="text"
              #input
              placeholder="Aircraft Type (ICAO)"
              aria-label="Aircraft Type (ICAO)"
              matInput
              (keyup)="check(input.value)"
              formControlName="aircraftType"
              [matAutocomplete]="type"
              (input)="onAircraftTypeChange()"
            />



           validateAircraft(value:string):void
           {
                  let match = false;
                  filteredAircraftTypes.map(x=>{ 
                  if(x.label===value)match=true})
                  if(!match)
                  {
                     // Add your code here
                  }


           }

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

Exploring the dynamic duo of SystemJS and AngularJS 2

I am currently working on integrating the Core Angular2 module into my application, which is written in Typescript. It's essentially following the same structure as the quick start tutorial on the Angular.IO website. However, I am facing a challenge ...

The module ~/assets/images/flags/undefined.png could not be found in the directory

When I use the img tag with a dynamic address filled using require, it works well in the component. However, when I try to write a test for it, an error is thrown. console.error Error: Configuration error: Could not locate module ~/assets/ima ...

How to measure the loading time of a component in Angular 7 and determine when it is fully rendered on the DOM

I am attempting to measure the time it takes for a component to fully load into the DOM. I found a solution that suggests using the following code snippet within the ngOnInit() function from this stackoverflow answer: ngOnInit() { var time = window.pe ...

Create an alternate name for a specific type of key within a nested record

There are three simple types available: const structureTypes = z.enum(["atom","molecule"]) const atomTypes = z.enum(["oxygen","hydrogen"]) const moleculeTypes = z.enum(["water","ammonia"]) The goal is to define a type for a cache where the keys correspond ...

Remove focus from input field after submitting in a project using Typescript and React with react-hook-form

I'm currently working on a TS-React project and encountering an issue with barcode scanning in my inputs. I am using react-hook-form along with the useForm Hook. The form consists of one input-text field and a submit button, both within a global form. ...

Disabling lint in a PhpStorm or WebStorm project with angular-cli

I am currently using PhpStorm version 2017.2, and I have created an angular-cli project within a directory that already contains several modules and components built with angular-cli. The issue I am facing is that I am inundated with countless linting err ...

Encountering authentication issues with Angular MSAL library following update to version 3.0.0-beta.0

Since updating my app from Angular v15 to v16 and from msal-angular 2.5.3 to 3.0.0-beta.0, I am encountering issues with authenticating against Azure AD B2C. An exception in the console is triggered when trying to execute MSAL's loginPopup(): app-erro ...

A TypeScript function designed to only process arrays consisting of objects that contain a specific property determined by another parameter, with the requirement that this property

function retrieveObjectRow<T = string>( arrayData: { [key: T]: number; [key: string]: unknown; }[], targetValue: number, specifiedField: T ): typeof arrayData[number] | null { for (let i = 0; i < arrayData.lengt ...

Optimal approach to configuring Spring Boot and Angular for seamless communication with Facebook Marketing API

Currently, I am working on a Spring Boot backend application and incorporating the Facebook marketing SDK. For the frontend, I am utilizing Angular 10. Whenever I create a new page or campaign, my goal is to send the corresponding object back to the fronte ...

Synchronized scrolling and equal height for multiple divs

Looking to create a system similar to GitHub's conflict resolver for my project. I have multiple versions represented by values in columns, and I want to be able to select different values from each column to create a new solution. It's important ...

PhpStorm is unable to resolve the @ionic/angular module

I have encountered a peculiar issue with my Ionic v4 project. While the project runs smoothly, PhpStorm seems unable to locate my references to @ionic. https://i.stack.imgur.com/umFnj.png Interestingly, upon inspecting the code, I realized that it is act ...

Provider in Angular2 that relies on multiple other Providers

Within my Angular2 application, I have various modules that offer Services and Configuration. Now, I want to integrate the @ngrx/store, which gathers reducers from all my modules. Below is the bootstrap code snippet: import {OpaqueToken} from 'angu ...

The scss function is returning an invalid property value

In my Angular project, I have organized my scss files/folders in the following way: 1) Settings - containing color settings and functions for the project 2) Files and folders defining variables such as fonts, widths, etc. for components and pages 3) Fil ...

Angular 14 captures typed form data as `<any>` instead of the actual data types

On the latest version of Angular (version 14), I'm experiencing issues with strictly typed reactive forms that are not functioning as expected. The form initialization takes place within the ngOnInit using the injected FormBuilder. public form!: For ...

Navigating through the complexities of managing asynchronous props and state in React-components

I'm really struggling to understand this concept. My current challenge involves passing asynchronously fetched data as props. The issue is that the props themselves are also asynchronous. Below is a simplified version of the component in question: i ...

Mastering the Correct Usage of AuthGuard

I am facing an issue with implementing authguard in my angular application. I have set up a post request to my spring boot backend, and upon success, I set a value to true which I then check in my canActivate method of the authguard. However, for some reas ...

Mismatch in TypeScript React Intl Redux form types encountered

Currently, I am facing an issue trying to connect my form to Intl and struggling with a TypeScript error. The error seems to disappear when I change injectIntl<any>, but then I'm not sure what exactly needs to be passed there. Can someone please ...

Getting into a dynamic named property inside another object in angular can be achieved by utilizing bracket notation

I encountered an issue in my Angular 8 project where I create an object from a JSON, but there is a dynamic property whose name is unknown until runtime. This causes problems when trying to access the value of that dynamic property within another object, l ...

Display the map using the fancybox feature

I have added fancybox to my view. When I try to open it, I want to display a map on it. Below is the div for fancybox: <div id="markers_map" style="display:none"> <div id="map_screen"> <div class="clear"></div> </div&g ...

increase the selected date in an Angular datepicker by 10 days

I have a datepicker value in the following format: `Fri Mar 01 2021 00:00:00 GMT+0530 (India Standard Time)` My goal is to add 60 days to this date. After performing the addition, the updated value appears as: `Fri Apr 29 2021 00:00:00 GMT+0530 (India St ...