title: Best Practice to chain two functions,, AngularJs/JavaScript
body: <p>I have TWO functions.</p>
  
  <p>One hides a modal when the 'close' button is clicked
  The other function swipes right and changes the modal to another state/view.</p>
  
  <p>I am having an issue with the modal NOT 'hiding' when the user swipes to the new state. I can see that it works but the modal remains on display and I was thinking that the best way to approach this is by chaining my two functions? Is this the correct terminology?</p>
  
  <p>The TWO functions.. </p>
  
  <p><strong>HIDES the modal</strong></p>
  
  <pre><code>$scope.closetripInfo = function() {
      $scope.modal.hide();
    };
  </code></pre>
  
  <p><strong>SWIPES right to reveal new .state</strong></p>
  
  <pre><code>$scope.onSwipeRight = function() {
    $state.go('app.current-trip');
  }
  </code></pre>
  
  <p><strong>This worked! BUT..</strong>
  What I was thinking of doing is plugging in my exciting <code>closetripInfo</code> function into the <code>onSwipeRight</code> Like so:</p>
  
  <pre><code>$scope.onSwipeRight = function() {
  
    $scope.closetripInfo();  
    $state.go('app.current-trip').closetripInfo();
  }
  </code></pre>
  
  <p>It works BUT it does not look right to me and I am getting an error.. I haven't been successful on doing it correctly. Perhaps is not that simple. I also think that I might need to be aware of best practices like promises? </p>
  
  <p><strong>THE ERROR</strong></p>
  
  <p><strong>TypeError: $state.go(...).closetripInfo is not a function
      at Scope.$scope.onSwipeRight</strong></p>
  
  <p>Any advice or resources would be greatly appreciated.Thank you! </p>