javascript - angularjs, how to update $http.post for the second time, ng-repeat?
習慣沉默
習慣沉默 2017-05-16 13:19:22
0
3
645

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>
習慣沉默
習慣沉默

reply all(3)
Ty80

Where is the search method triggered?

世界只因有你

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

Ty80

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

htmlContent = $compile(htmlContent)($scope);
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template