material-select doesn't accept numbers as selected valu


Topic: material-select doesn't accept numbers as selected value

Starceaker asked 7 years ago

In the material select it's possible to add an array of entries with a number as a value. However when binding ngModel to a number property it throws an exception because the code behind checks explicitly for string values. https://mdbootstrap.com/angular/advanced/material-select/ get value(): string | string[] { return this.multiple ? this._value : this._value[0]; } set value(v: string | string[]) { if (typeof v === 'undefined' || v === null || v === '') { v = []; } else if (typeof v === 'string') { v = [v]; } else if (!Array.isArray(v)) { throw new TypeError('Value must be a string or an array.'); } if (!OptionList.equalValues(v, this._value)) { this.optionList.value = v; this.valueChanged(); } }
Hi, thank you for noticing, we will think about adding this in the future.
Please insert min. 20 characters.

FREE CONSULTATION

Hire our experts to build a dedicated project. We'll analyze your business requirements, for free.

Status

Answered

Specification of the issue
  • User: Free
  • Premium support: No
  • Technology: MDB Angular
  • MDB Version: -
  • Device: -
  • Browser: -
  • OS: -
  • Provided sample code: No
  • Provided link: No