@@ -64,27 +64,25 @@ angular.module('crunchinatorApp.controllers')
6464 //Bind component data services to the scope, so we can use them in the views
6565 $scope . ComponentData = ComponentData ;
6666
67+ var deferred = $q . defer ( ) ;
68+ function applyFilters ( ) {
69+ _ . delay ( function ( ) {
70+ $scope . $apply ( function ( ) {
71+ Company . runFilters ( filterData ) ;
72+ Category . runFilters ( filterData ) ;
73+ Investor . runFilters ( filterData ) ;
74+
75+ deferred . resolve ( 'Finished filters' ) ;
76+ } ) ;
77+ } , 300 ) ;
78+
79+ return deferred . promise ;
80+ }
81+
6782 //All of our filters broadcast 'filterAction' when they've been operated on
6883 //When a filter receives input we set up filterData and run each model's filters
6984 //This should automatically update all the graph displays
7085 $scope . $on ( 'filterAction' , function ( ) {
71- var deferred = $q . defer ( ) ;
72-
73-
74- function applyFilters ( ) {
75- _ . delay ( function ( ) {
76- $scope . $apply ( function ( ) {
77- Company . runFilters ( filterData ) ;
78- Category . runFilters ( filterData ) ;
79- Investor . runFilters ( filterData ) ;
80-
81- deferred . resolve ( 'Finished filters' ) ;
82- } ) ;
83- } , 300 ) ;
84-
85- return deferred . promise ;
86- }
87-
8886 $scope . loading = true ;
8987 filterData . categoryIds = _ . pluck ( $scope . selectedCategories , 'id' ) ;
9088 filterData . companyIds = _ . pluck ( $scope . selectedCompanies , 'id' ) ;
@@ -102,5 +100,7 @@ angular.module('crunchinatorApp.controllers')
102100 $scope . loading = false ;
103101 } ) ;
104102 } ) ;
103+
104+
105105 }
106106] ) ;
0 commit comments