Ion-select unselect or clear button


#1

Is there a way to allow the user to clear (unselect) a selection they made on a ion-select ( multiple=“false”)? I understand that it’s using radio buttons and by default there is no such an option in a radio button but is there a way to add a button somewhere to do this?

Thanks


#2

Hi Javasol,

You can achieve solution with the help of Angularjs.

Hope this will help.

Happy Holidays! :slight_smile:

Aditya Kumar

1- ng-disabled - disables a given control.
2- ng-show- shows a given control.
3- ng-hide -hides a given control.
4- ng-click -represents a AngularJS click event.

ng-disabled directive:

<input type = "checkbox" ng-model = "enableDisableButton">Disable Button
<button ng-disabled = "enableDisableButton">Click Me!</button>

ng-show directive:

<input type = "checkbox" ng-model = "showHide1">Show Button
<button ng-show = "showHide1">Click Me!</button>

ng-hide directive:

<input type = "checkbox" ng-model = "showHide2">Hide Button
<button ng-hide = "showHide2">Click Me!</button>

ng-click directive:

<p>Total click: {{ clickCounter }}</p>
<button ng-click = "clickCounter = clickCounter + 1">Click Me!</button>

Example

<html>
   
   <head>
      <title>AngularJS HTML DOM</title>
   </head>
   
   <body>
      <h2>AngularJS Sample Application</h2>
      <div ng-app = "">
         
         <table border = "0">
            <tr>
               <td><input type = "checkbox" ng-model = "enableDisableButton">Disable Button</td>
               <td><button ng-disabled = "enableDisableButton">Click Me!</button></td>
            </tr>
            
            <tr>
               <td><input type = "checkbox" ng-model = "showHide1">Show Button</td>
               <td><button ng-show = "showHide1">Click Me!</button></td>
            </tr>
            
            <tr>
               <td><input type = "checkbox" ng-model = "showHide2">Hide Button</td>
               <td><button ng-hide = "showHide2">Click Me!</button></td>
            </tr>
            
            <tr>
               <td><p>Total click: {{ clickCounter }}</p></td>
               <td><button ng-click = "clickCounter = clickCounter + 1">Click Me!</button></td>
            </tr>
         </table>
         
      </div>
      
      <script src = "https://ajax.googleapis.com/ajax/libs/angularjs/1.3.14/angular.min.js"></script>
      
   </body>
</html>

#3

Thanks for the reply but I’m not sure how to implement this on an ion-select component. I understand I could put a button somewhere on the page that would allow the user to clear values on click but it would make more sense to have the button on the ion-select popup itself


#4

hi javasol just add a none option to your select tag .