Input field is not loading default value "value"

Asked

Viewed 1,076 times

1

I got the field:

<div class="form-group">
 <label style="color:white" for="valor">Valor</label>
   <div class="input-group">
      <input type="number" value = "0" class="form-control" step="any" name="valor" ng-model="contato.valor" required>

...

But the field is not initializing with the value set in value.

Can someone help me?

  • 1

    I believe he will consider ng-model. Try setting the default value in $scope.valor or use ng-value.

1 answer

1

This happens because you have one ng-model. The value of this input is the ng-model, probably you are not passing anything to this model, why it will go empty.

Go to your controller and enter a value for this Model, in your case, you want the value to be 0.

Then go to your controller and put:

$scope.contato.valor = 0

Read more about the Ng-Model here

Browser other questions tagged

You are not signed in. Login or sign up in order to post.