Join GitHub today
GitHub is home to over 40 million developers working together to host and review code, manage projects, and build software together.
Sign up$mdDialog: locals not working! #455
Comments
This comment has been minimized.
This comment has been minimized.
Locals injects things into the controller, not onto the scope. mdDialog.show({locals: { name: 'Bob' }, controller: 'myController'});
module.controller('myController', function($scope, name) {
$scope.name = name;
}); |
This comment has been minimized.
This comment has been minimized.
You can also do it a bit more conveniently inline: $mdDialog.show({
locals: { name: 'Bob' },
controller: ['$scope', 'name', function($scope, name) {
$scope.name = name;
}]
}); |
This comment has been minimized.
This comment has been minimized.
Cool! |
This comment has been minimized.
This comment has been minimized.
Thanks, a bit that can be easily overlooked looking at the example. Why do we have such roundabout way of passing parameters to mdDialog.show? |
This comment has been minimized.
This comment has been minimized.
Because it has an isolated scope. "The dialog is always given an isolate scope." from https://material.angularjs.org/latest/#/api/material.components.dialog/service/$mdDialog |
This comment has been minimized.
This comment has been minimized.
This isn't 100% accurate. You can pass your own scope (but if you don't then a new isolate scope will be created and used). |
This comment has been minimized.
This comment has been minimized.
What about passing scope data from the dialog into the parent one? |
This comment has been minimized.
This comment has been minimized.
cool! |
This comment has been minimized.
This comment has been minimized.
Hello, I'm not sure whether I'm doing something wrong but <md-button ng-click='listObjects.viewDetailsDialog($event, object)'> and also this this.viewDetailsDialog = (ev, obj) => {
$mdDialog.show({
templateUrl: 'client/objects/list-objects/view-details.dialog.html',
clickOutsideToClose: true,
openFrom: {top: -50, width: 30, height: 80},
closeTo: {left: 500},
preserveScope: true,
targetEvent: ev,
locals: { item: obj }
});
} the EDIT: Ok, I've just got it working by changing the this.viewDetailsDialog = (ev, obj) => {
$mdDialog.show({
templateUrl: 'client/objects/list-objects/view-details.dialog.html',
clickOutsideToClose: true,
openFrom: {top: -50, width: 30, height: 80},
closeTo: {left: 500},
preserveScope: true,
targetEvent: ev,
locals: { item: obj },
controller: ['$scope', 'item', function($scope, item) {
$scope.item = item;
}]
});
} |
This comment has been minimized.
This comment has been minimized.
3 things:
|
This comment has been minimized.
This comment has been minimized.
@ViruSzZ - Please look at |
Hi,
The locals option for $mdDialog service is not working: how to pass objects to the dialog scope?