簡體   English   中英

貸款計算器

[英]Loan Calculator

我是Angular JS的新手。 我試圖用Angular JS創建一個貸款計算器,原型似乎運行良好。

我想問一下所有Angular的專家,是否有更好的方法(使用框架)為兩個利率只寫一個公式。 實際上,我這樣做是由於以下功能:

function totalCalc(years, amount) {
    calc = (((amount * 9.9 * years) /1200)/12) + (amount / (years*12));
    $scope.total = currencyRround(calc);

    calc2 = (((amount * 12.5 * years) /1200)/12) + (amount / (years*12));
    $scope.total2 = currencyRround(calc2);
}

我當時想用ng-repeat來完成這項工作,定義利率如下:

$scope.interests= [
    {
        rate: '9.9'
    },{
        rate: '12.5'
    }
];

然后將值集成到forEach中,如下所示:

angular.forEach($scope.interests, function(s){
    interest = s.rate;
}

但是我沒有足夠的經驗去進一步思考...您是否認為這可能是完成工作的好方法?

這是帶有“原型”的JSFiddle: http : //jsfiddle.net/645Xs/2/

感謝您的幫助 :)

 <div class="item">
            <h1>Rata mensile in CHF:</h1>
            <h2 ng-repeat='rate in [9.9,12.5]'>
                {{rate}} = {{(((one * rate * (two / 12)) /1200)/12) + (one / two) | number:2}}
            </h2>
        </div>

更新的小提琴

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM