ahmed elbarbary

ahmed elbarbary

  • NA
  • 1.6k
  • 275.3k

How to get id from list when text input match or equal items

Dec 25 2019 8:57 PM

problem

How to get id from list when text input match or equal items exist on list ?

I work on angular 7

I have input text on nvabar.Component.html write on it part name as following :

  1. <mat-form-field class="example-full-width">    
  2.     <input matInput placeholder="Enter name" [(ngModel)]="partname" >    
  3.   </mat-form-field>    

I need when write on text input Transistor part then I will search on list parts and get partid =2 .

  1. navbar.component.ts  export class NavBarComponent implements OnInit { public parts = [  { id: 1, partname: 'hummer', }, { id: 2, partname: 'Transistor', }, { id: 3, partname: 'Air', }  ]; ngOnInit() { }

So How to get partid from list when textbox text matched items on list ?


Answers (1)