Open VanNNT opened 7 years ago
Html:
<select2 [data]="listMajor | async" [options]="options" [value]="valueMajor"></select2>
Component:
public listMajor: Observable<Select2OptionData[]>; this.listMajor = this.searchService.getMajor(); this.options = { multiple: true }; this.valueMajor = [4307, 4308];
Service:
getMajor(): Observable<Select2OptionData[]> { return this._http.get(this.constant.MAJOR) .map((response: Response) => response.json()) .map((majors) => { majors.unshift({id:'0',name:''}); return majors.map((major) => { return {id: major.id, text: major.majorName}; }); }) }
I try to binding [value] but not work. When list Major is Array, it can binding [value]. I also try to convert Observable<Select2OptionData[]> to Array, but I don't know how do it. How can binding [value]? Should I take in mind any issue? Thank you.
Html:
Component:
Service:
I try to binding [value] but not work. When list Major is Array, it can binding [value]. I also try to convert Observable<Select2OptionData[]> to Array, but I don't know how do it. How can binding [value]?
Should I take in mind any issue?
Thank you.