Angularjs 在表格中以四列为一行显示角度数组值
我想在表中以四列为一行显示角度数组字符串值。 该数组具有如下值:Angularjs 在表格中以四列为一行显示角度数组值,angularjs,Angularjs,我想在表中以四列为一行显示角度数组字符串值。 该数组具有如下值: ["str1", "str2", "str3","str4","str5","str6","str7","str8" and so on] 我希望将其显示在包含四列的表中,以便该表如下所示: col1 col2 col3 col4 -------------------------- str1 str2 str3 str4 str5 str6 str7 str8 我的控制器代码: $s
["str1", "str2", "str3","str4","str5","str6","str7","str8" and so on]
我希望将其显示在包含四列的表中,以便该表如下所示:
col1 col2 col3 col4
--------------------------
str1 str2 str3 str4
str5 str6 str7 str8
我的控制器代码:
$scope.output=["str1", "str2", "str3","str4","str5","str6","str7","str8" ....]
var one=[];
var two=[];
var three=[];
var four=[];
for( var i=1; i<=$scope.output.length ;i++)
{
if((i)%4==0){
one.push($scope.output[i]);
}
else if((i)%4==1)
{ two.push($scope.output[i]);}
}
else if((i)%4==2)
{ three.push($scope.output[i]);}
}
else if((i)%4==3)
{ four.push($scope.output[i]);}
}
$scope.output = {one: one , two: two , three : three , four :four};
$scope.output=[“str1”、“str2”、“str3”、“str4”、“str5”、“str6”、“str7”、“str8”…]
VarOne=[];
var-two=[];
var三=[];
var四=[];
对于(var i=1;i{{output.three[$index]}
{{output.four[$index]}
但是上面的代码不能解决问题。如何解决这个问题?像这样试试
var-app=angular.module(“app”,[]);
app.controller(“MyCtrl”,函数($scope){
$scope.index=0;
$scope.items=[“str1”、“str2”、“str3”、“str4”、“str5”、“str6”、“str7”、“str8”、“str9”、“str10”];
$scope.array=[];
对于(var i=0;我可以设置一个plunkr吗?你看了吗?很好的答案,我认为这很完美。你看到我的答案了吗?是的,我看到了很好的逻辑,这就是我向你解释的方式
<table>
<tr ng-repeat="one in output.one track by $index" >
<td><div>{{one}}</div></td>
<td><div>{{output.two[$index]}}</div></td>
td><div>{{output.three[$index]}}</div></td>
<td><div>{{output.four[$index]}}</div></td>
</tr>
</table>