使用新数据角度刷新数据表

时间:2014-05-20 16:50:53

标签: angularjs datatable reload

我有一个带有一些问题和答案的数据表。当页面加载时,“aviation.json”被放入数据表中。在组合框中选择另一个值后,需要更新数据表中的数据。但这不起作用,有人知道我做错了吗?

HTML

        选择您的类别:     

<table ng-table="tableParams" show-filter="true" class="table ng-table-rowselected" id="questionsTable">
    <tr ng-repeat="user in $data"
        ng-click="user.$selected = !user.$selected; changeSelection(user)"
        ng-class="{'active': user.$selected}">
        <td data-title="'Category'" sortable="'Category'" filter="{ 'Category': 'text' }">
            {{user.Category}}
        </td>
        <td data-title="'Question'" sortable="'Question'" filter="{ 'Question': 'text' }">
            {{user.Question}}
        </td>
    </tr>
</table>

代码

$ scope。$ watch('comboCat',function(){         的console.log($ scope.comboCat.name);

    switch ($scope.comboCat.name){
        case "Aviation": console.log("aviaton selected");
            $http.get('aviation.json').success(function(data){
                $scope.data = data;
                console.log("get json aviaton");
            });
            break;
        case "Customer care": console.log("customer care selected");
            //$scope.data = $http.get('customerCare.json');
            $http.get('customerCare.json').success(function(data){
                $scope.data = data;
            });
            break;
        case "Finance": console.log("Finance selected");
            $http.get('finance.json').success(function(data){
                $scope.data = data;
            });
            break;
    }
});

0 个答案:

没有答案