0
Angular JS newbee question。Angular JS詳細搜索
我有一個控制器從數據庫中獲取的數據:
var app = angular.module('myApp', []);
app.controller('myAppCtrl', ['$scope', '$http', function ($scope, $http) {
$http.get("views/resumen.pedidos.php")
.success(function (data) {
$scope.results = data;
});
該數據顯示在表:
<body ng-app="myApp">
<div ng-controller="myAppCtrl" class="row top-row">
<table id="data-table" border="0" width="100%" cellpadding="0" cellspacing="0" class="table panel">
<thead>
<tr>
<th>PEDIDO</th>
<th>ESTADO WEB</th>
<th>FECHA</th>
<th>HORA</th>
<th>PREPARAR</th>
<th>CANTIDAD</th>
<th>PREPARADO</th>
<th>ENVIO</th>
</tr>
</thead>
<tbody>
<tr ng-repeat="result in results">
<td>{{ result.pedido }}</td>
<td>{{ result.estado_web | uppercase }}</td>
<td>{{ result.fecha }}</td>
<td>{{ result.hora }}</td>
<td>{{ result.preparar }}</td>
<td>{{ result.cantidad }}</td>
<td>{{ result.enviado }}</td>
<td>{{ result.envio }}
</tr>
</tbody>
</table>
</div>
</body>
我希望顯示來自其他控制器的數據單擊錶行的時候,使用{{result.pedido}}作爲鍵值。
app.controller('myAppDetailCtrl', ['$scope', '$http', function ($scope, $http) {
$http.get("views/detalle.pedidos.php")
.success(function (data) {
$scope.results = data;
});
你有兩個選項,首先:單擊行時,將行數據注入到服務中並從中獲取數據。二:通過url傳遞數據,並使用'$ location.search();'得到它 – Isma90