How can I clean a Select and set its default value to an angularJs form?

0
<div class="input-field col s12" style="margin-top: 30px; margin-bottom:10px; ">
      <select ng-model="formData.estadoActi" name="form.estadoActi">
       <option value="" disabled selected >Selecciona la opcion</option>
      <option value="En proceso">En proceso</option>
  <option value="Terminada">Terminada</option>

      </select>
   <label >Seleccione el estado</label>

I want to know how I can create a function in angularjs so that when I press a button, the select will take its default value which would select its status . Try modifying putting its value empty but it did not work since the same value that I had selected keeps appearing and the idea is that I put the default value:

  $scope.reset = function() {
    $scope.form.estadoActi="";

  };
    
asked by Jctd 03.09.2017 в 19:21
source

1 answer

1

The name of the model you have in the ng-model tag is not the same as the one you have in the script.

In the html you have:

<select ng-model="formData.estadoActi" name="form.estadoActi">

While in the script:

 $scope.form.estadoActi=""

The names have to be the same. Replace

<select ng-model="formData.estadoActi" name="formData.estadoActi">

By:

 <select ng-model="form.estadoActi" name="formData.estadoActi">

Or vice versa, as you understand.

    
answered by 04.09.2017 в 19:29