This question already has an answer here:
-
How to set default selected values in multiselect with ngModel in Angular 2
4 answers
I am using Select with multiple selection component.
I want to make 2 items to be selected by default like this.
I have surfed,but i got resources only for Basic select component, How can i achieve this?
I have done it here please check https://stackblitz.com/edit/angular-zs2wa5?file=app/select-multiple-example.ts
export class SelectMultipleExample {
toppings;
toppingList: string[];
constructor() {
this.toppings = new FormControl();
this.toppingList= ['Extra cheese', 'Mushroom', 'Onion', 'Pepperoni', 'Sausage', 'Tomato'];
this.toppings.value = ['Mushroom', 'Onion', ];
console.log(this.toppings);
}
}