在输出输入新值后不能修改默认值 [英] Can't changes default value after inputting new values in output

查看:151
本文介绍了在输出输入新值后不能修改默认值的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我很新的angularJS

I am very new to angularJS

下面是我CONTROLER

Below is my controler

var app = angular.module('ChildPlanning', ['rzModule', 'ui.bootstrap']);
app.controller('MainCtrl', function($scope, $rootScope, $timeout, $modal)

 $scope.ir ={
   value:8
 };
 $scope.result1 = pv*(Math.pow((1+(rateofreturn.value/100)), tenure.value));
 $scope.result2 = ((((annuityrate.value/100)/ 12 )*(Math.pow((1+((annuityrate.value/100)/ 12 )), lifeexpectancy.value*12)));

 $scope.annuity_future = $scope.ir.value * $scope.result1  * $scope.result2;
}

我的HTML

输入HTML 1

<input name="inflation" type="text" id="ir" ng-model="ir.value" >

HTML输出

 <span>{{ annuity_future }}</span>

当我手动输入字段中输入改变输入ir.value的默认值,输出值不会相应地改变。

When i am manually changing the default value of in input "ir.value" by typing in input field, the value in output is not changing accordingly

要做到这一点,thisway因为我必须做,有很多变量和变化非常大,我使用有我面临着同样的问题。

Want to do this, thisway because i have to to do a long mathematical operation with lots of variable and with very variable i am using there i am facing the same issue

在此先感谢

推荐答案

添加到您的code:

$scope.change = function(){
  $scope.annuity_future = $scope.ir.value * $scope.result1  * $scope.result2;
};

和本替换你输入标签:

<input name="inflation" type="text" id="ir" ng-model="ir.value" ng-change="change()">

注意:确保你的计算是有效的,因为我得到了,我错过了一个错误有一个

Note: make sure your calculations are valid, because I got an error that I missed one ).

这篇关于在输出输入新值后不能修改默认值的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆