Search code examples
angularjsinputnumbersangular-ngmodel

angular getting error on `input type number` , ngModel:numfmt on "01234"


i have an error on setting a value in controller like this 01234 and turning it to string for not removing the 0

and getting error on input type number for using the string as a value , i want to showing the zero in input field and cant switch to input type text !


Solution

  • You can just use type tel

    <input type="tel" ng-model="myNumber">
    

    and then in controller

    $scope.myNumber = "01234";
    

    See this plunker http://plnkr.co/edit/Y5GQiLpENthi7ccok5hJ?p=preview enter image description here