Thursday, September 17, 2015

Angular UI-Select Clear

                          
When we are using UI-Select  we need to reset the selected Item. 
We can achieve this by using

Html


<ui-select id="organization" ng-model="data.SelectedOrganization" class="form-control-static" on-select="onSelectedOrg()" >
                <ui-select-match placeholder=" select a organization...">
                {{$select.selected.Text}}
                </ui-select-match>
                <ui-select-choices repeat="org in data.Organizations | propsFilter: {Text: $select.search}"
                                   refresh="refreshOrgs($select.search)"
                                   refresh-delay="0">
                    <div ng-bind-html="org.Text | highlight: $select.search"></div>
                </ui-select-choices>
            </ui-select>

<input id="clear" type="Button" value="Clear"  ng-click="clear()" />
Javascript

$scope.clear = function () {
                $scope.data.SelectedOrganization = undefined;
                
            };

No comments:

Post a Comment