title: Angularjs Pass form which is inside modal controller to ng-controller outside modal
body: <p>So I am a bit confused as to why this doesn't work:</p>
  
  <p>My main Angular page has an ng-controller called "SearchCtrl" which contains a bunch of logic for sending searches to a webserver.</p>
  
  <pre><code>app.controller('SearchCtrl', ['$http','$scope', function($http,$scope) {
  
  $scope.doAlert = function() {
      console.log('search page alert inside searchresultsctrl');
  }
  </code></pre>
  
  <p>This controller is included on my search page,and then somewhere down the page there is another controller, SearchSortModalCtrl, which will pop open a modal and let users do some stuff:</p>
  
  <pre><code>app.controller('SearchSortModalCtrl', function ($scope, $modal, $log) {
  .....
  
  var modalInstance = $modal.open({
          templateUrl: '/modal-search-sort.html',
          controller: 'SearchSortFormCtrl',
          size: size,
          resolve: {
              items: function () {
                return $scope.items;
              }
          }
      });
  </code></pre>
  
  <p>That is connected to this controller:</p>
  
  <pre><code>app.controller('SearchSortFormCtrl', ['$http','$scope','$rootScope','$modalInstance', function($http,$scope,$rootScope,$modalInstance) {
  
      $scope.cancel = function () {
          $modalInstance.dismiss();
      };
  
      $scope.doAlert2 = function() {
          console.log('search page alert test2');
      }
  </code></pre>
  
  <p>So anyhow, what I am trying to do is to put an ng-submit inside the modal form, and when that form is submitted, it will do some logic on the SearchCtrl.</p>
  
  <p>But if I do </p>
  
  <pre><code>ng-submit="doAlert()"
  </code></pre>
  
  <p>inside my modal, it will not work or send anything to SearchCtrl, but if I change it to doAlert2() it will of course run on the SearchSortFormCtrl. I tried making it</p>
  
  <pre><code>ng-submit="$parent.doAlert()"
  </code></pre>
  
  <p>but no dice and to show you what level I'm flailing away on I even tried</p>
  
  <pre><code>ng-submit="$parent.$parent.doAlert()"
  </code></pre>
  
  <p>and that did nothing.</p>
  
  <p>What am I doing wrong, or how can I get this form to just do stuff in the SearchCtrl?</p>