I set a rootScope variable in my run block like so:
.run(['$rootScope', 'numbersService', function($rootScope, numbersService) {
numbersService.getAvailableCodes().$promise.then(function(data) {
$rootScope.availableCodes = data.codes;
});
}]);
I need $rootScope.availableCodes
to be available in order for my filter to run properly. Here is the beginning of my filter code:
.filter('formatValue', ['$rootScope', function($rootScope) {
var availableCodes = $rootScope.availableCodes;
...
My problem is that since $rootScope.availableCodes
is set based on an async call it is not guaranteed to be available when my filter runs (this filter appears in dozens of places throughout my HTML). How can I wait to run the rest of my filter logic until $rootScope.availableCodes
is set?
No comments:
Post a Comment