Hi, I posted an issue on github trying to get some users to help but they 
seem to be confused as to what's going on, as I am. 

Link to that, and the feedback I've 
gotten: 
http://stackoverflow.com/questions/30117637/angularjs-injecting-scope-without-into-a-controller

Original post: 

In the Material Design mdDialog documentation 
<https://material.angularjs.org/#/api/material.components.dialog/service/$mdDialog>,
 
I’ve noticed that they’ve passed a scope (without a prefixed dollar sign) 
to the DialogController near the bottom.

(function(angular, undefined){
  "use strict";
  angular
   .module('demoApp', ['ngMaterial'])
   .controller('AppCtrl', AppController);
  function AppController($scope, $mdDialog) {
    var alert;
    $scope.showAlert = showAlert;
    $scope.showDialog = showDialog;
    $scope.items = [1, 2, 3];
    // Internal method
    function showAlert() {
      alert = $mdDialog.alert({
        title: 'Attention',
        content: 'This is an example of how easy dialogs can be!',
        ok: 'Close'
      });
      $mdDialog
        .show( alert )
        .finally(function() {
          alert = undefined;
        });
    }
    function showDialog($event) {
       var parentEl = angular.element(document.body);
       $mdDialog.show({
         parent: parentEl,
         targetEvent: $event,
         template:
           '<md-dialog aria-label="List dialog">' +
           '  <md-dialog-content>'+
           '    <md-list>'+
           '      <md-list-item ng-repeat="item in items">'+
           '       <p>Number {{item}}</p>' +
           '      '+
           '    </md-list-item></md-list>'+
           '  </md-dialog-content>' +
           '  <div class="md-actions">' +
           '    <md-button ng-click="closeDialog()" class="md-primary">' +
           '      Close Dialog' +
           '    </md-button>' +
           '  </div>' +
           '</md-dialog>',
         locals: {
           items: $scope.items
         },
         controller: DialogController
      });
      function DialogController(scope, $mdDialog, items) {
        scope.items = items;
        scope.closeDialog = function() {
          $mdDialog.hide();
        }
      }
    }})(angular);

I've read that $ is a naming convention and a good way to make sure 
variables don't get overwritten. Why is this code failing to follow that 
convention? I.e in this context, how do we know when to use $ or not, and 
what is the significance? I believe in this case it must be more than just 
the naming convention, or the authors would have chosen to use $scope for 
purposes of consistency.

NOTE: I am aware of the difference between $scope and scope in linking 
functions, where scope is pointing to a fixed set of parameters. I do not 
believe that is why scope is used in this context, but feel free to let me 
know if I am wrong.

I am thinking that this is how promises are returned from mdDialog? Is that 
the case, or is that not how it works at all? 



Thanks for any help. 

Follow Polymer on Google+: plus.google.com/107187849809354688692
--- 
You received this message because you are subscribed to the Google Groups 
"Polymer" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/polymer-dev/55b516a1-bdda-4efb-9537-b521765bbda9%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to