Sub DCF()
Dim z As Double, CashFlow As Double, DiscRate As Double, Periods As Double: z = 0#
CashFlow = InputBox("Enter initial cash flow: ", "Cash Flow")
DiscRate = InputBox("Enter discount rate in decimal form: ", "Discount Rate")
Periods = InputBox("How many periods (in years) are there?", "Periods")
Dim i As Integer
For i = 1 To Periods:
z = z + CashFlow / (1# + DiscRate) ^ i
Next
MsgBox Format(z, "$0.00")
End Sub
这是我的html输入。当我添加一个整数值时,它的工作正常。但是,如果我添加0000 ng-change only fire,首先输入0.这是我的java脚本。
<input name="maxSalary" id="MaxSalary" type="number" min="0" class="form-control" ng-model="dp.maximumSalary" ng-change="minMaxSalaryComparision()" />
任何想法?
答案 0 :(得分:1)
使用ng-keyup
或ng-keydown代替ng-change
<input name="maxSalary" id="MaxSalary" type="number" min="0" class="form-control" ng-model="dp.maximumSalary" ng-keyup="minMaxSalaryComparision()" />
<强>样本强>
angular.module("Demoapp",[])
.controller("Democtrl",function($scope){
$scope.minMaxSalaryComparision = function () {
alert($scope.dp.maximumSalary);
};
})
&#13;
<script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.4.8/angular.min.js"></script>
<div ng-app="Demoapp" ng-controller="Democtrl">
<input min="0" class="form-control" ng-model="dp.maximumSalary" ng-keyup="minMaxSalaryComparision()" />
</div>
&#13;
答案 1 :(得分:1)
ng会发生更改。由于0000
等于0
,因此更改不会被触发。
或者可以使用ngKeyup
在密钥释放时触发此事件
angular.module("app",[])
.controller("ctrl",function($scope){
$scope.minMaxSalaryComparision = function () {
alert($scope.dp.maximumSalary);
};
})
&#13;
<script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.2.23/angular.min.js"></script>
<div ng-app="app" ng-controller="ctrl">
<input name="maxSalary" id="MaxSalary" type="number" min="0" class="form-control" ng-model="dp.maximumSalary" ng-keyup="minMaxSalaryComparision()" />
</div>
&#13;