智能表未在setTimeout上刷新

时间:2017-07-05 07:35:05

标签: javascript angularjs smart-table

与表生成相关的代码不适用于以下函数

function populateDataTable(repo_contributor,repo_langauges){
    $scope.rowCollection = [
        {firstName: 'Laurent', lastName: 'Renard', birthDate: new Date('1987-05-21'), balance: 102, email: 'whatever@gmail.com'},
        {firstName: 'Blandine', lastName: 'Faivre', birthDate: new Date('1987-04-25'), balance: -2323.22, email: 'oufblandou@gmail.com'},
        {firstName: 'Francoise', lastName: 'Frere', birthDate: new Date('1955-08-27'), balance: 42343, email: 'raymondef@gmail.com'}
    ];

 for (var key in repo_contributor){
    console.log(repo_contributor[key]);
    var repo_table_data = {};
    repo_table_data['repo_name'] = key; 
    repo_table_data['contributors'] = repo_contributor[key].toString();
    repo_table_data['languages'] = repo_langauges[key].toString();
     console.log(repo_table_data);
    $scope.repo_info_list.push(repo_table_data);
}
    console.log("here now");
    console.log($scope.repo_info_list.length);

}

populateDataTable由以下代码填充

setTimeout(populateDataTable,4000,$scope.repo_contributor,$scope.repo_languages);

$scope.rowCollection正在设置但未显示在表格上(表格为空)。

但如果$scope.rowCollection位于populateDataTable之外,则会使用正确的值填充表格。

非常感谢您的帮助。

3 个答案:

答案 0 :(得分:0)

你必须尝试这样

setTimeout(function() {            
   populateDataTable($scope.repo_contributor,$scope.repo_languages);
  }, 4000)

答案 1 :(得分:0)

在setTimeOut中尝试这样的箭头函数:

setTimeout( ()=> {            
   populateDataTable($scope.repo_contributor,$scope.repo_languages);
  }, 3000)

答案 2 :(得分:0)

如Hadi所述,setTimeout不起作用,但函数参数的超时工作。

$timeout(populateDataTable, 4000,true,$scope.repo_contributor,$scope.repo_languages)