javascript - Default input number value -
i'm new angularjs , i've created simple input box want default value.
here's input:
<input id="fieldwidth" min="10" type="number" value="10" ng-model="set.width">
however, value doesn't show default.
when try set though scope in controller
$scope.set.width = "10";
it says
"cannot set property 'width' of undefined"
what missing?
if haven't already... should set $scope.set before trying set it's child:
$scope.set = {width:10};
or
$scope.set = {}; $scope.set.width = 10;
or can without set object if don't have other values associating it.
$scope.width = 10;
<input id="fieldwidth" min="10" type="number" ng-model="width">
Comments
Post a Comment