-
Notifications
You must be signed in to change notification settings - Fork 3.4k
How to pass an angular-material list to an angular-material dialog? #1413
Comments
Use the angular
.module('yourApp')
.controller('AppCtrl', function ($scope) {
$scope.items = [0, 1, 2, 3];
$mdDialog.show({
controller: 'DialogController',
templateUrl: 'dialog1.tmpl.html',
locals: {
items: $scope.items
}
});
});
angular
.module('yourApp')
.controller('DialogController', function ($scope, items) {
// items is injected in the controller, not its scope!
$scope.items = items;
}); |
Got it to work. Thanks for pointing me in the right direction. |
If you use controllerAs, you can make it shorter too. myApp.controller('AppCtrl', function($scope, $mdDialog) {
$scope.items = [1,2,3];
$mdDialog.show({
controller: function Ctrl() {},
controllerAs: 'ctrl',
templateUrl: 'dialog1.tmpl.html',
locals: {
items: $scope.items
}
});
}); Then you can just reference |
@darylyu - in the future, these types of questions should be posted in the Angular Material Forum |
Reopen - need to update Dialog docs. |
@ThomasBurleson I have a PR open for dialog docs: #1411 |
Closing as more detail was added to the mdDialog docs. Feature request discussion is still open in #1531. |
then you can use {{locals.imageUrl}} |
Thank you very much for point me in the right direction. |
|
Did You inject locals to ManageProductController args? Example controller('DialogCtrl', function ($scope, $mdDialog, locals) { |
no pls this type of question is helpful for me because https://groups.google.com/forum/#!forum/ngmaterial can't be searched by google |
nice , its helped me |
I struggled to make @ajoslin 's version work since it is the simplest, but couldn't. I had to use this method for controller definition (parameter injection)
|
I'm following this as my guide: https://material.angularjs.org/#/demo/material.components.dialog
I've got a $scope.items inside AppCtrl, but I don't know how to make DialogController display it in dialog1.tmpl.html.
The text was updated successfully, but these errors were encountered: