Reputation: 1
I open a dialog with mdDialog when checking a checkbox (in the example checkbox 1). Within this dialog there are several input fields, which should be connected via ng-modell to a controller - but it seems, that is not the scope used by the main controller (in the example myCtrl).
How can I use the same scope in the dialog and myCtrl? I tried locals to access the parent scope, but this didn't work.
Here is the plunker:
[https://plnkr.co/edit/9biRK5oskpQRhRWyeHWd](https://plnkr.co/edit/9biRK5oskpQRhRWyeHWd)
Upvotes: 0
Views: 513
Reputation: 11
Remove the loacals. It can use myCtrls scope.
<md-radio-group ng-model="dialog_radio1">
Then in the cancel function I was able to log the selected radio value from myCtrls' scope.
$scope.cancel = function () {
$mdDialog.cancel();
console.log($scope.dialog_radio1);
};
Upvotes: 0
Reputation: 3184
just pass the $scope
to $mdDialog.show
$mdDialog.show({
scope: $scope,
controller: function () {
// ...
}
});
Upvotes: 2