angular2-mdl-ext
angular2-mdl-ext copied to clipboard
object item with id=0 is not selectable
unsuccessfully i am trying to pick first value of an array of objects. but without multiple="true" this code works fine
sphere =[{id:0,name:'wewe'},{id:1,name:'ghjghj'}]
<mdl-select [(ngModel)]="sphere" multiple="true" placeholder="Select countries">
<mdl-option mdl-ripple *ngFor="let c of work_sphere" [value]="c.id">{{c.name}}</mdl-option>
</mdl-select>
did some research and found out that inside method MdlSelectComponent.prototype.writeValue value==0 equal value==null or undefined i added strict comparison with 0 and just in case with '0' and problems gone
if ((value!==0 && value!=='0' && !value) || this.ngModel === value) {
}
else if (Array.isArray(value)) {
this.ngModel = uniq(this.ngModel.concat(value));
}
else if (this.ngModel.indexOf(value) != -1) {
this.ngModel = this.ngModel.filter(function (v) { return v !== value; }).slice();
}
else if (!!value || value===0 || value==='0') {
this.ngModel = this.ngModel.concat([value]);
}
can you add someting like this little rafactoring in repo?
Hi, a pull request would be great!