我有一個數據庫表,其中有許多行,每個行都有5個字段。然後我有一個<div>
元素,我想在其中顯示一行的字段。什麼是 從我的表中檢索行並使用div顯示行的字段的最佳方式是什麼?使用AngularJS在div元素中顯示錶格的行
目前我有一個服務,檢索表中的所有行,一個控制器,調用上述服務,並在控制器我 有每個行的字段。這就是我的意思:
// service
...
getTableRows: function(callback) {
$http.post('../php/getTableRows.php')
.success(function(data, status, headers, config) {
callback(data);
})
.error(function(errorData) {
console.log("error: " + errorData);
});
}
// controller
...
myService.PHP.getTableRows(function(getTableRowsResponse){
// getTableRowsResponse contains all of my rows in the table in an array
//getTableRowsResponse[0].name;
//getTableRowsResponse[0].ID;
//getTableRowsResponse[0].age;
//getTableRowsResponse[0].department;
//getTableRwosResponse[0].imageurl;
});
// view
...
<div class="widget">
//how do I access the fields here?
</div>