I have a datatable with some questions and answers. When the page is loaded, "aviation.json" is placed in a datatable. After choosing a different value in the combobox, the data in the datatable needs to be updated. But this does not work, does anyone know what I am doing wrong?
HTML
Select a category:
<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>
The code
$ 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");
$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;
}
});
Warri source
share