2013-12-15 77 views
0

希望在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); 

回答

2

總結你的代碼的函數:

$timeout(function(){ 
    $scope.applyParameters($routeParams.param1); 
}, 5000); 

目前$scope.applyParameters($routeParams.param1)評估和角度嘗試調用applyParameters返回值的函數。