0

Is it possible or is there a better way I can run the execute function after $scope.found has been returned where the seeker function is initiated by an ng-click event.

 $scope.adder = {
            seeker:function(){
                $scope.found = null;
                $scope.found = $scope.services.find(function(service){
                    return service;
                });
                Loader.showLoading('Added to cart');
                return $scope.found;
            },
            execute:function($scope,found){
                if($scope.found != null){
                    $scope.cart.addItem(found.title, found.pricing, found.qty);
                    Loader.hideLoading();
                }
            }
        }
Austin
  • 19
  • 1
  • 8
  • The 2nd function executes immediately by doing this, ng-click"$scope.adder.seeker(); $scope.adder.execute()" so I end up with a Can't find variable: found error – Austin Apr 05 '16 at 09:09
  • Creating a wrapper member function is nice here! The wrapper will set a promise for the first function. When it is finished finding the service, the promise will resolve and then you can call the 2nd function! – Victor Benetatos Apr 05 '16 at 09:16

0 Answers0