title: How to use the same controller with an Angular Material dialog?
body: <p>I'm using Angular Material within my project. I use many dialogs (just for alert purposes), but I now require quite a complex dialog.</p>
  
  <p>This is the example that the Angular Material site uses:</p>
  
  <pre><code>function showDialog($event) {
    var parentEl = angular.element(document.body);
    $mdDialog.show({
      parent: parentEl,
      targetEvent: $event,
      template: '&lt;md-dialog aria-label="List dialog"&gt;' +
        '  &lt;md-dialog-content&gt;' +
        '    &lt;md-list&gt;' +
        '      &lt;md-list-item ng-repeat="item in items"&gt;' +
        '       &lt;p&gt;Number {{item}}&lt;/p&gt;' +
        '      ' +
        '    &lt;/md-list-item&gt;&lt;/md-list&gt;' +
        '  &lt;/md-dialog-content&gt;' +
        '  &lt;md-dialog-actions&gt;' +
        '    &lt;md-button ng-click="closeDialog()" class="md-primary"&gt;' +
        '      Close Dialog' +
        '    &lt;/md-button&gt;' +
        '  &lt;/md-dialog-actions&gt;' +
        '&lt;/md-dialog&gt;',
      locals: {
        items: $scope.items
      },
      controller: DialogController
    });
  
    function DialogController($scope, $mdDialog, items) {
      $scope.items = items;
      $scope.closeDialog = function() {
        $mdDialog.hide();
      }
    }
  }
  </code></pre>
  
  <p>Instead, would be it possible to not reference a <code>controller</code> for the <code>$mdDialog</code>, and to just allow it to use the same controller where it was called from?</p>
  
  <p>For example, if it is called via this button, the dialog would simply use the <code>MyCtrl</code> controller so that the dialog can access the scope variables.</p>
  
  <pre><code>&lt;div ng-controller="MyCtrl"&gt;
    &lt;md-button ng-click="showDialog($event)" class="md-raised"&gt;
      Custom Dialog
    &lt;/md-button&gt;
  &lt;/div&gt;
  </code></pre>
  
  <p>Is this a possibility? Or must I continually use the <code>locals</code> property along with broadcasting to keep passing variables back and forth?</p>