0

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)

2 Answers 2

2

just pass the $scope to $mdDialog.show

$mdDialog.show({
    scope: $scope,
    controller: function () {
        // ...
    }
});
Sign up to request clarification or add additional context in comments.

1 Comment

great! That did it!! Thanks
0

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);
                        };

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.