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

刚开始使用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>
習慣沉默
習慣沉默

最新下载
更多>
网站特效
网站源码
网站素材
前端模板
关于我们 免责声明 Sitemap
PHP中文网:公益在线PHP培训,帮助PHP学习者快速成长!