您希望在延迟5秒后执行applyParameters功能。但是我当前的语法没有这样做。
有关如何做到这一点的想法吗?
//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);
答案 0 :(得分:2)
将代码包装在函数中:
$timeout(function(){
$scope.applyParameters($routeParams.param1);
}, 5000);
目前评估$scope.applyParameters($routeParams.param1)
,Angular会尝试将applyParameters
的返回值作为函数调用。