Ber*_*nie 1 javascript angularjs
我想在AngularJS中创建一个表,它应该是这样的:
id | weekday | time | Actions 1 | Mon | 10:10 | Edit-Link, Delete-Link 2 | Tue | 15:19 | Edit-Link, Delete-Link
我的代码是:
<html ng-app>
...
<script type="text/javascript">
function DB($scope) {
$scope.currentQs = null;
$scope.jsons = JSON.parse('${jsons}');
$scope.edit = function(id) {
console.log("Edit " + id);
}
$scope.delete = function(id) {
console.log("Delete " + id);
}
}
</script>
<body ng-controller="DB">
<table>
<tbody ng-repeat="qs in jsons">
<tr>
<td>{{qs.query_id}}</td>
<td>{{qs.weekday}}</td>
<td>{{qs.hour}}:{{qs.minute}}</td>
<td>
<!-- I guess, I'm thinking in the wrong way with the a-tags -->
<!-- How do I put the current object (qs) as $scope.currentQs -->
<a href="#" ng-click="edit('{{qs.query_id}}')">Edit</a>
<a href="#" ng-click="delete('{{qs.query_id}}')">Delete</a>
</td>
</tr>
</tbody>
</table>
</body>
</html>
好的,桌子很好.但是设置Edit-和Delete-Link的正确方法是什么?
谢谢.伯恩哈德
PS:昨天刚开始看AngularJS.
在内部,ng-click您不需要插值,{{ }}因为它已经在角度执行上下文中:
<a href="#" ng-click="edit(qs.query_id)">Edit</a>
<a href="#" ng-click="delete(qs.query_id)">Delete</a>
Run Code Online (Sandbox Code Playgroud)
所以,上面应该对你有用.
| 归档时间: |
|
| 查看次数: |
3071 次 |
| 最近记录: |