在Angular 1.6中,当用户删除输入内的值时,这些值被设置为“未定义”。它似乎是AngularJS中的默认行为。如何在用户删除AngularJS 1.6中的值时将输入值自动设置为空(而不是“未定义”)?
HTML
<input ng-model="name" class="form-control" id="inp_name"
placeholder="My Name" required="true" value="" />
控制器
...
$scope.name = ""; <-- here the initial value is correctly set up as empty
...
$scope.submit = function(){
alert($scope.name); <-- the value can be "undefined" if the user removed all the string
};
如何自动设置的值作为空的,而不是“未定义”每次文本输入是在前端空?