如何使用角度js中两个数组的数据来填充表格

时间:2016-12-12 12:04:29

标签: javascript angularjs arrays

我的控制器中有两个范围变量

$scope.data.items and $scope.bf_data 

现在bf_data的大小始终是data.items的倍数。

我正在使用这样的数据填充表格

<table>
          <tr>
            <th><div style="width: 100px" >Id</div></th>
            <th><div style="width: 250px" >Details</div></th>
            <th><div style="width: 150px" >Score</div></th>
            <th><div style="width: 70px" >HPSA Score</div></th>
            <th><div style="width: 55px" >BF Score</div></th>
	    <th><div style="width: 50px" >BF Sum</div></th>
            <th><div style="width: 75px" >BQ Score</div></th>
	    <th><div style="width: 50px" >BQ Sum</div></th>
            <th><div style="width: 70px" >Classifier Score</div></th>
            <th><div style="width: 70px" >Word Match</div></th>
	    <th><div style="width: 70px" >Minreva Score</div></th>
          </tr>
          <tr ng-repeat="x in data.items  " >
            <td><a href="{{ x.get }}">{{ x.id }}</td>
            <td>
                <p><b>{{ x.name[0] }}</b></p>
                <p><u>Brand</u>: {{ x.Brand }}; <u>Category URL</u>: {{ x.mlnURL }};<u>Price</u>: Rs {{x.Price}} </p>
            </td>
            <td>
                <p><a href="{{x.explain}}"><b>{{ x.score }}</b></a></p>
                Classifier Score: {{ x.cscore }} <br>
                Document Score: {{ x.sscore }} </p>
            </td>
            <td>
                <p><b> {{ x.hpsaScore_default }} </b></p>
            </td>
            <td>
                <p><b> {{ x.bf_value }} </b></p>
            </td>
	    <td>
                <p><b> {{ x.bf_value_sum }} </b></p>
            </td>
            <td>
                <p><b> {{ x.bq_value }} </b></p>
            </td>
	     <td>
                <p><b> {{ x.bq_value_sum }} </b></p>
            </td>
            <td>
                <p> <b> {{ x.cscore }} </b></p>
            </td>
            <td>
                <p> <b> {{ x.wordMatch }} </b></p>
            </td>
	    <td>
                <p> <b> {{ x.minrevaScore }} </b></p>
            </td>
          </tr>
        </table>

现在在这个表之间我想插入来自bf_data数组的数据。对于第一行,我想从bf_data数组中首先打印$ scope.data.items.length / $ scope.bf_data.items.length元素。在新行中下一个$ scope.data.items.length / $ scope.bf_data.items.length项等等......

如何做到这一点。

我修改了控制器,现在每个项目都有一个相应的数组,其值来自bf_data。现在我需要做的就是在前一个语句中使用另一个ng-repeat语句但它不起作用。

代码看起来像这样

 <table>
          <tr>
            <th><div style="width: 100px" >Id</div></th>
            <th><div style="width: 250px" >Details</div></th>
            <th><div style="width: 150px" >Score</div></th>
            <th><div style="width: 70px" >HPSA Score</div></th>
            <th><div style="width: 55px" >BF Score</div></th>
	    <th><div style="width: 50px" >BF Sum</div></th>
            <th><div style="width: 75px" >BQ Score</div></th>
	    <th><div style="width: 50px" >BQ Sum</div></th>
            <th><div style="width: 70px" >Classifier Score</div></th>
            <th><div style="width: 70px" >Word Match</div></th>
	    <th><div style="width: 70px" >Minreva Score</div></th>
	    <th><div style="width: 70px" >BF</div></th>
          </tr>
          <tr ng-repeat="x in data.items  " >
            <td><a href="{{ x.get }}">{{ x.id }}</td>
            <td>
                <p><b>{{ x.name[0] }}</b></p>
                <p><u>Brand</u>: {{ x.Brand }}; <u>Category URL</u>: {{ x.mlnURL }};<u>Price</u>: Rs {{x.Price}} </p>
            </td>
            <td>
                <p><a href="{{x.explain}}"><b>{{ x.score }}</b></a></p>
                Classifier Score: {{ x.cscore }} <br>
                Document Score: {{ x.sscore }} </p>
            </td>
            <td>
                <p><b> {{ x.hpsaScore_default }} </b></p>
            </td>
            <td>
                <p><b> {{ x.bf_value }} </b></p>
            </td>
	    <td>
                <p><b> {{ x.bf_value_sum }} </b></p>
            </td>
	   	
            <td>
                <p><b> {{ x.bq_value }} </b></p>
            </td>
	     <td>
                <p><b> {{ x.bq_value_sum }} </b></p>
            </td>
            <td>
                <p> <b> {{ x.cscore }} </b></p>
            </td>
            <td>
                <p> <b> {{ x.wordMatch }} </b></p>
            </td>
	    <td>
                <p> <b> {{ x.minrevaScore }} </b></p>
            </td>
	    <td ng-repeat="y in x.bf_val " >
		<td>
                <p> <b> {{ y }} </b></p>
            	</td>
	    </td>
          </tr>
        </table>

我追加数组内容的最后一部分没有给出正确的输出

0 个答案:

没有答案