Home Close $mdDialog from different component
Reply: 0

Close $mdDialog from different component

user1425
1#
user1425 Published in May 22, 2018, 9:21 pm

I have a button in my CardKnowledgeDB.html

<button ng-click="vm.launchContactActivityPopup()">Contact</button>

It calls this function in my CardKnowledgeDBComponent.ts

public launchContactActivityPopup(): void {
    this.$mdDialog.show({
        template: `
            <md-dialog class="add-contact-moment-popup">
                <register-contact-activity-popup></register-contact-activity-popup>
            </md-dialog>`,
        targetEvent: null,
        clickOutsideToClose: false,
    });
}

public cancel(): void {
    this.$mdDialog.cancel();
}

I have a ResponsiveNavigation component that has a a href button inside the template to return to the homepage. When I click it and return to the homepage I want to close the current $mdDialog.

So how do I reference the $mdDialog that's in the CardKnowLedgeDBComponent.ts from my ResponsiveNavigationComponent.ts?

Or is there a global way to close all $mdDialog views?

// EDIT // ANWSER

You can just add

public removeMdDialog() {
    this.$mdDialog.cancel();
}

(and Inject the mdDialog) and you have a global function to close a $mdDialog.

You need to login account before you can post.

About| Privacy statement| Terms of Service| Advertising| Contact us| Help| Sitemap|
Processed in 0.305087 second(s) , Gzip On .

© 2016 Powered by mzan.com design MATCHINFO