我創建一個web應用程序中,我計算了textbox
一個$scope
變量,但如果用戶把textbox
空,或者如果用戶不上textbox
輸入任何結果未來NaN
這裏是我的代碼angularjs楠正在出現,如果文本框爲空
<input type="text" ng-model="amount1" ng-blur="amountchange(amount1)" />
{{total}}
在我控制器我
$scope.amountchange = function() {
$scope.total = parseInt($scope.amount1) + parseInt($scope.total);
}
我想擺脫掉NaN
如果文本框爲空時被apearing
這裏是我更好地理解
['提琴$ scope.total = parseInt($ scope.amount1)+ parseInt($ scope.total)|| 200;'](https://jsfiddle.net/tusharj/XNVj3/2252/) – Tushar