我有来自另一个程序员的脚本,它给html提供了一个列表。我怎样才能只返回单个值,然后将它们添加到html?
$scope.getResult = function() {
$scope.result = [];
PAPFields.forEach( function( field ) {
var name = field[ field.length - 1 ];
$scope.result.push( [ field[ 0 ], name, +window[ name ] ] );
} );
};
答案 0 :(得分:-1)
请使用for()代替forEach
$scope.getResult = function() {
$scope.result = [];
for(var i = 0; i < PAPFields.length; i++){
var name = PAPFields[i][ field.length - 1 ];
$scope.result.push( [ PAPFields[i][ 0 ], name, +window[ name ] ] );
}
};