How can preselect value in angular ui select editing

581 Views Asked by At

I am using angular schema form anf use ui select to populate options.

Now i am binding my object with id of the choices. Here is the template

<ui-select
        ng-model="$select.selected"
        theme="bootstrap"
        ng-disabled="disabled"
        on-select="$$value$$=$select.selected.id"
        >
    <ui-select-match placeholder="Please Select ">{{$select.selected.display}}</ui-select-match>
    <ui-select-choices repeat="a in choices">
        <div ng-bind-html="a.display"> {{ a.display }}</div>
    </ui-select-choices>
</ui-select>

I wasn't ben able to bind my $$value$$ to id of the selected object. so for hack i added this

on-select="$$value$$=$select.selected.id"

$$value$$ represents the model.myobject so on select i am manually binding id to that property.

For new object this works fine.

But when i need to edit object then that option is not preselected.

Any ideas how can i do that

There is a addon for ui select for schema form and i got idea from it. But i could not fully understood it

https://github.com/chengz/schema-form-uiselect/blob/master/src/single.html

0

There are 0 best solutions below