javascript - angularjs,第二次$http.post,ng-repeat怎麼更新?
習慣沉默
習慣沉默 2017-05-16 13:19:22
0
3
586

剛開始使用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>
習慣沉默
習慣沉默

全部回覆(3)
Ty80

search方法在哪觸發的?

世界只因有你

檢查的時候發現了,版面中間多了一個

頁面上沒看出來
Ty80

可能angular要再編譯下,坑多。 。 。

htmlContent = $compile(htmlContent)($scope);
熱門教學
更多>
最新下載
更多>
網站特效
網站源碼
網站素材
前端模板
關於我們 免責聲明 Sitemap
PHP中文網:公益線上PHP培訓,幫助PHP學習者快速成長!