I would like to find a way to clear the selection of a ui-select by code.
For example I have the following code
<ui-select ng-model="selectedCustomerCode" ng-if="CustomerIds.length>1" on-select="CustomerCodeFiltersOnSelectCallback($item, $model)" theme="bootstrap">
<ui-select-match class="ui-select-match" allow-clear="true" placeholder="Επιλογή κωδικού πελάτη...">{{$select.selected.CCode}}</ui-select-match>
<ui-select-choices class="ui-select-choices" repeat="customer in CustomerIds | propsFilter: {CCode: $select.search}">
<div ng-bind-html="customer.CCode | highlight: $select.search"></div>
</ui-select-choices>
</ui-select>
I want to clink on a clear button and clear some inputs including the ui-select. What is the code in order to clear ui-select?
You should clear cont.selectedCustomerCode
variable:
<button ng-click="cont.selectedCustomerCode = ''">clear</button>
Edit:
You should consider exposing you attributes on a variable. That's the recommended way.