angularJS中的數據表不起作用當我ng-repeat
對象從$http.get
這裏是前。 (第一個表的作品,第二個表不工作)https://codepen.io/bafu2203/pen/VzBVmy
JS:
var app=angular.module('formvalid', ['ui.bootstrap','ui.utils']);
app.controller('validationCtrl',function($scope, $http, $timeout){
$scope.getapi = function(){
$http({
method: 'GET',
url: 'https://www.w3schools.com/angular/customers_mysql.php',
})
.then(function successCallback(data) {
$scope.test = data.data.records;
console.log($scope.test);
$timeout($scope.getapi, 1000);
}, function errorCallback(response) {
console.log(response);
console.log('error');
});
};
$scope.getapi();
$scope.data={ "records":[ {"Name":"Alfreds Futterkiste","City":"Berlin","Country":"Germany"}, {"Name":"Ana Trujillo Emparedados y helados","City":"México D.F.","Country":"Mexico"}, {"Name":"Antonio Moreno Taquería","City":"México D.F.","Country":"Mexico"}, {"Name":"Around the Horn","City":"London","Country":"UK"}, {"Name":"B's Beverages","City":"London","Country":"UK"}, {"Name":"Berglunds snabbköp","City":"Luleå","Country":"Sweden"}, {"Name":"Blauer See Delikatessen","City":"Mannheim","Country":"Germany"}, {"Name":"Blondel père et fils","City":"Strasbourg","Country":"France"}, {"Name":"Bólido Comidas preparadas","City":"Madrid","Country":"Spain"}, {"Name":"Bon app'","City":"Marseille","Country":"France"}, {"Name":"Bottom-Dollar Marketse","City":"Tsawassen","Country":"Canada"}, {"Name":"Cactus Comidas para llevar","City":"Buenos Aires","Country":"Argentina"}, {"Name":"Centro comercial Moctezuma","City":"México D.F.","Country":"Mexico"}, {"Name":"Chop-suey Chinese","City":"Bern","Country":"Switzerland"}, {"Name":"Comércio Mineiro","City":"São Paulo","Country":"Brazil"} ] }
$scope.dataTableOpt = {
//custom datatable options
// or load data through ajax call also
"aLengthMenu": [[10, 50, 100,-1], [10, 50, 100,'All']],
"aoSearchCols": [
null
],
};
});
什麼「不工作」?兩張桌子都很適合我。他們都充滿了數據。爲什麼這個問題甚至得到upvotes? –
過濾不起作用 – bafix2203