Angular2 reactive forms select multiple attribute?

痞子三分冷 提交于 2019-12-04 10:21:54

Bind to the multiple property at the select level to a boolean isMultiple. Then you can change it and the select will change as well. Take a look at the this, I change it using a button. plnkr

  <select formControlName="cars" [multiple]="isMultiple">
      <option></option>
      <option *ngFor="let car of cars" >{{car}}</option>
  </select>

It seems when adding the multiple property it is affecting the required validator. I was able to just add an extra validator and it worked as expected.

Validators.compose([Validators.required,Validators.pattern('.+')]
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!