power-select]1. The options i pass to power select comes from a service. The option array has duplicate values which i try to remove in my controller. I have made a twiddle put since it ember-twiddle does not support addonss (ember-power-select) till now. I have modified it little bit Ember twiddle
The comment code in twiddle is what I have on desktop. This code works in tweedle but does not work on my computer.
Issue: dropDown value is not visible on template
import Ember from 'ember';
const {
get,
set,
computed
} = Ember;
export default Ember.Service.extend({
locations: computed(function(){
var self = this;
return get(this,'store')
.findAll('store')
.then(stores =>{
let locs = stores.map(store => {
return get(store,'adminAreaLevel2') +" "+ get(store,'adminAreaLevel1')
});
set(self,'locations',locs);
});
});
And the code in controller is
//Controller
import Ember from 'ember';
const {
inject: { service },
computed: { uniq }
}=Ember;
export default Ember.Controller.extend({
dropData: service('my-service'),
dropLocation: uniq('dropData.locations')
});
The power-select-code that I cannot include in twiddle
{{#power-select
options=dropLocation
selected=selectedLoc
matcher=locMatcher
onchange=(action "selectLoc") as |loc|}}
{{first-caps loc}}
{{/power-select}}
{{/bs-form-group}}
UPDATES
Hi @Bek thanks for solution some one suggest me same in ember slack community. the problem with this solution is dropLocation: uniq('dropData.locations')
does not get updated as uniq does not work with promise array properly. I have come up with ugly solution but it work.
dropLocation: Ember.computed('dropData.locations',function(){
return this.get('dropData.locations')
.then(data => data.uniq());
})
Looking for good solution