Javascript 时滞角函数
Hi希望在5秒延迟后执行applyParameters功能。然而,我目前的语法并不能做到这一点 你知道怎么做吗Javascript 时滞角函数,javascript,angularjs,Javascript,Angularjs,Hi希望在5秒延迟后执行applyParameters功能。然而,我目前的语法并不能做到这一点 你知道怎么做吗 //Add and update categories var categories = homeData['categories']; for(var catIndex in categories){ var category = categories[catIndex];
//Add and update categories
var categories = homeData['categories'];
for(var catIndex in categories){
var category = categories[catIndex];
$scope.addCategory(category);
}
$scope.search.text = homeData['keyword'];
//Pick first company in the results
$scope.updateSelectedCompany( response.data[0] );
//populate parameters if passed in after 1 second delay
$timeout($scope.applyParameters($routeParams.param1), 5000);
将代码包装到函数中:
$timeout(function(){
$scope.applyParameters($routeParams.param1);
}, 5000);
当前,$scope.applyParameters($routeParams.param1)
被计算,Angular尝试调用applyParameters
的返回值作为函数