Home  >  Q&A  >  body text

javascript - angularjs, how to update $http.post for the second time, ng-repeat?

I just started using angularjs, and now paging and querying are done by the background,
So I think it might be good if I use $http again to update $scope
But now ng-repeat is in search( ) I can receive the data and the page does not change
This is my current code.
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>
習慣沉默習慣沉默2736 days ago622

reply all(3)I'll reply

  • PHP中文网

    PHP中文网2017-05-16 13:21:22

    Where is the search method triggered?

    reply
    0
  • 世界只因有你

    世界只因有你2017-05-16 13:21:22

    I discovered during inspection that there is an extra </p> in the middle of the layout which was not visible on the page

    reply
    0
  • PHP中文网

    PHP中文网2017-05-16 13:21:22

    Maybe angular needs to be compiled again, and there are many pitfalls. . .

    htmlContent = $compile(htmlContent)($scope);

    reply
    0
  • Cancelreply