剛開始使用angularjs,現在分頁和查詢都是由後台完成的,
所以我想我再用一次$http更新一下$scope可能就好了
但現在ng-repeat在search( )後我能接收到數據,頁面不會改變
這是我目前的程式碼。
js
app.controller('checkpoint', function($scope, $http) {
//getData to list
$http({
method: 'post',
url: '../list',
}).then(function successCallback(response) {
$scope.checkpoint = response.data.datas.list;
}, function errorCallback(response) {
console.log('请求错误');
});
//search
$scope.search = function (){
$http({
method: 'post',
params :{keyword:$scope.query},
url: '../list',
}).then(function successCallback(response) {
console.log(response.data.datas.list)
$scope.checkpoint = response.data.datas.list;
}, function errorCallback(response) {
console.log('请求错误');
});
};
});
html
<p class="rule_serch" ng-controller="checkpoint">
...
<tr ng-repeat="x in checkpoint">
<td>{{ x.projectCode }}</td>
<td>{{ x.station }}</td>
<td>{{ x.code }}</td>
<td>{{ x.circuit }}</td>
<td>{{ x.name }}</td>
<td>{{ x.item }}</td>
<td>{{ x.description }}</td>
<td>{{ x.watchedAssetCode }}</td>
</tr>
...
</p>