在表中显示结果

Displaying result in a table

本文关键字:结果 显示      更新时间:2023-09-26

大家早上好,

我已经创建了一个脚本,一旦我让它正常工作,我将在我的网站上实现。

你能帮我出个结果吗。

有一个for循环为我做了一些计算,但结果似乎在1行,而不是在垂直列中,我看不出哪里出了问题,请帮忙。

var myApp = angular.module('myApp', []);
var startingValue = 3;
var VXP = [2.41, 2.50, 1.80, 1.56, 1.43, 1.35, 1.30, 1.26, 1.23, 1.20, 1.18, 1.17, 1.16, 1.14, 1.13, 1.13, 1.12, 1.11, 1.11, 1.10, 1.10, 1.09, 1.09, 1.08, 1.08];
var text = "";
var i;
for (i = 0; i < VXP.length; i++) {
    startingValue *= VXP[i];
    vxpResult = text += Math.floor(startingValue);
}

function MyCtrl($scope) {
    $scope.level = i;
    $scope.vxp = vxpResult;
}

http://jsfiddle.net/rppge4cm/2/

这是因为您正在连接一个长字符串。尝试使用数组保存值:

var i;
var vxpResult = [];
for (i = 0; i < VXP.length; i++) {
    startingValue *= VXP[i];
    vxpResult.push(Math.floor(startingValue));
}
function MyCtrl($scope) {
    $scope.level = i;
    $scope.vxp = vxpResult;
}

演示:http://jsfiddle.net/rppge4cm/3/