【发布时间】:2016-04-08 02:43:34
【问题描述】:
我想在用户数组上进行迭代移动,并用数组中的唯一用户填充每个 td,但我不想在每个 ng-repeat 的步骤中重复并生成新的 html 代码。
我只想在 td 上移动一下,对于每一个,在 td 中放置一个用户。
<!DOCTYPE html>
<html ng-app="fill">
<head>
<?php include "includes/head.php" ?>
<script type="text/javascript">
(function(){
var fill=angular.module("fill",[]);
fill.controller("fillTable",function($scope){
$scope.users=[ {name:"jack"},
{name:"joe"},
{name:"alen"},
{name:"mina"},
{name:"mari"},
{name:"karen"}
];
});
})()
</script>
</head>
<body>
<table ng-controller="fillTable" border=1>
<tbody ng-repeat="user in users">
<tr>
<td>user 1:{{user.name}}</td>
<td>user 2:{{user.name}}</td>
</tr>
<tr>
<td>user 3:{{user.name}}</td>
<td>user 4:{{user.name}}</td>
</tr>
<tr>
<td>user 5:{{user.name}}</td>
<td>user 6:{{user.name}}</td>
</tr>
</tbody>
</table>
</body>
</html>
实际上,我有一个包含四列的网格,它是由语义 ui-grid 创建的。 现在我想从数据库的表格中阅读许多文章然后我将这些数据放在网格的列中。{就像“pinterest 风格”页面}a pic for more explain , please see it
【问题讨论】:
-
使用任何数据表插件...
-
或者创建一个返回你想要的 html 代码的方法:generateHtml()... ng-repeat 有一个明确的目的,重复 html 标签。
-
感谢您的意见。是否有任何其他角度指令可以移动元素并为我们做点什么?为什么我会得到 2 个否定标记?
标签: javascript html angularjs ng-repeat semantic-ui