Angularjs wait until

Posted by Diolor on Stack Overflow See other posts from Stack Overflow or by Diolor
Published on 2013-10-17T11:41:54Z Indexed on 2013/10/17 21:54 UTC
Read the original article Hit count: 415

I have:

$scope.bounds = {}

And later in my code:

$scope.$on('leafletDirectiveMap.load', function(){
    console.log('runs');
    Dajaxice.async.hello($scope.populate, {
                'west' : $scope.bounds.southWest.lng,
                'east': $scope.bounds.northEast.lng,
                'north' : $scope.bounds.northEast.lat,
                'south': $scope.bounds.southWest.lat,
    });
});

The bounds as you can see at the begging they are empty but they are loaded later (some milliseconds) with a javascript library (leaflet angular). However the $scope.$on(...) runs before the bounds have been set so the 'west' : $scope.bounds.southWest.lng, returns an error with an undefined variable.

What I want to do is to wait the bounds (southWest and northEast) to have been set and then run the Dajaxice.async.hello(...).

So I need something like "wait until bounds are set".

© Stack Overflow or respective owner

Related posts about angularjs

Related posts about angularjs-directive