我對AngularJs頗爲新穎,並創建了一個表格。每行都是從控制器內聲明的JsonArray中讀取數據。但是,這些行是空的。在Json數組中顯示錶格行內的數據 - AngularJs
的代碼如下所示:https://jsfiddle.net/00x8bwp0/9/
<body>
<div class="container">
<div class="row row-content" ng-controller="tableController">
<div class="col-xs-12 col-sm-9" >
<h2>Facts & Figures</h2>
<div class="table-responsive">
<table class="table table-striped">
<tr>
<th>Name</th>
<th>Date of Birth</th>
<th>Gender</th>
<th>Salary</th>
</tr>
<tr ng-repeat="employee in employees">
<td>{{employee.name}}</td>
<td>{{employee.dateOfBirth | date:"dd/MM/yyyy" }}</td>
<td>{{employee.gender }}</td>
<td>{{employee.salary | number:2}}</td>
</tr>
</table>
</div>
</div>
</div>
</div>
<script src="../bower_components/angular/angular.min.js"></script>
<script>
var app = angular.module('filterApp',[]);
app.module('tableController',function(){
var employees = [
{
name: "Ben", dateOfBirth: new Date("November 23, 1980"),
gender: "Male", salary: 55000.788
},
{
name: "Sara", dateOfBirth: new Date("May 05, 1970"),
gender: "Female", salary: 68000
},
{
name: "Mark", dateOfBirth: new Date("August 15, 1974"),
gender: "Male", salary: 57000
},
{
name: "Pam", dateOfBirth: new Date("October 27, 1979"),
gender: "Female", salary: 53000
},
{
name: "Todd", dateOfBirth: new Date("December 30, 1983"),
gender: "Male", salary: 60000
}
];
this.employees = employees;
});
</script>
有什麼不對?
謝謝,
泰奧。
我把在頁面的頂部。而且還沒有任何反應:(。我還沒有檢查$注入的事情,但我想它必須做一些依賴注入(我在Android開發中使用它很多) – Theo
@Theo檢查注入,因爲它是最很重要的一部分數據綁定(綁定視圖和控制器) – StepUp
我很肯定,這可以在沒有注入的情況下解決 – Theo