SHORT ANSWER
Do not use property binding (brackets []) for multiple property:
<select id="placeType"
class="form-control"
multiple
style="height:200px"
formControlName="kalase">
<option value="" selected disabled>Select Place Type</option>
<option *ngFor="let kalase of types"
[value]="kalase"
[innerHtml]="kalase"></option>
</select>
LONGER ANSWER
Multiple select and option are Angular directives.
select directive iterates over options and decides whether select it or not:
this._optionMap.forEach(optionSelectedStateSetter);
which calls internal option's function _setSelected:
/** @internal */
_setSelected(selected: boolean) {
this._renderer.setProperty(this._element.nativeElement, 'selected', selected);
}
In case of <select [miltiple]="true" ..., during this iteration, multiple property is not yet rendered on 'select' element (Angular did not evaluate it yet), thus select element is treated as single and only last option (in the order of types array) is set as selected.
Only after this iteration multiple property will be rendered by Angular and from this point on, the select element will act properly. So even running:
setTimeout(this.placeForm.get('kalase').setValue(this.placeForm.value.kalase));
would "fix" the problem, because reactive form's model is correct and select element now is multiple.
To see incorrect options value, you can run in console:
[...document.querySelector('#placeType')].map(x => `${x.value}: ${x.selected}`)
which will give you:
'': false
'BAR': false
'CAFE': false
'RESTAU': false
'hotels': true
'club': false
In case of <select multiple ..., the element from the very beginning acts as multiple, thus setting option as selected indeed selects them.
Now, running previous debug query will give:
'': false
'BAR': false
'CAFE': true
'RESTAU': false
'hotels': true
'club': false
If for any reason, you need multiple property be conditional, I would recommend to use *ngIf or setting default value or values using setTimeout along with reactive form's model (as I already demonstrated)
STACKBLITZ
kalaseto an array of an array of arrays? Maybe the code should bekalase: [this.types[1], this.types[3]]? Remove the first inner array. Too many square brackets?