title: Angular: how to call a function after changing state
body: <p>I am building a small message system. I use tabs in my state (inbox, outbox). Also, i want to sent a message when i click a "contact" link. If i click that link, this should happen:</p>
  
  <ol>
  <li>change state to messages state</li>
  <li>open other tab, called "newmsg"</li>
  </ol>
  
  <p>At this moment, this is what i have:</p>
  
  <pre><code>&lt;a ng-click="mailContact()"&gt;contact&lt;/a&gt;
  </code></pre>
  
  <p>and i my controller:</p>
  
  <pre><code>$scope.mailContact = function() {
        $state.go('root.messages');
        $scope.openTab('new');
      };
  </code></pre>
  
  <p>Obviously this is not working, because $scope.openTab('new'); will never execute. The state changes to what i want, but the tab is not opened. I do not have a clue of how to get it done.</p>