Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

To make default selection in autocomplete (material)

I am using autocomplete component(i,e Display value autocomplete) for my project.Here is the stackblitz example

How can i set a any one list item as default ? like this enter image description here

like image 784
PGH Avatar asked Aug 27 '18 06:08

PGH


2 Answers

Use FormControl SetValue method to set Default Value

this.myControl.setValue( {name: 'Mary'});

Example:https://stackblitz.com/edit/angular-8r153h

like image 62
Chellappan வ Avatar answered Sep 23 '22 08:09

Chellappan வ


set Initial value of FormControl

myControl = new FormControl({name: 'Shelley'});
like image 35
Krishna Rathore Avatar answered Sep 22 '22 08:09

Krishna Rathore