Nassim
Nassim

Reputation: 131

angularjs zeros missing within number input

I have problem with zeros like above :

in html I have :

<div class="form-group form-group-default">
   <label>Numéro</label>
   <input class="form-control" style="margin-bottom: 11px;" placeholder="(+33)57 24 05 99" ng-model="produit.telephone">
</div>

the model is:

telephone: {type: Number, default: null}

when I put a number which has zero on the left, it will not be considered.

for instance when I put 0160206576, it will be saved as 160206576

Upvotes: 1

Views: 167

Answers (2)

daan.desmedt
daan.desmedt

Reputation: 3820

Change the type number, for allowing preloading 0, to String

telephone: {type: String, default: null}

Upvotes: 0

Darin Cardin
Darin Cardin

Reputation: 657

If it has zeros in the front, it must be stored as a string, like this:

 app.controller("main",function($scope){
   $scope.produit.telephone = "0160206576";

  });

Upvotes: 3

Related Questions