I followed official https://material.angular.io/components/dialog/overview where it states that if the dialog component itself has to be closed, we need to inject MdDialogRef reference as below and then close on an event
export class LoginDialogComponent {
constructor(public dialogRef: MdDialogRef<LoginDialogComponent>,
@Inject(MD_DIALOG_DATA) public data: any, public afAuth: AngularFireAuth, private router: Router) {
}
closeDialog(): void {
this.dialogRef.close();
}
signInWithGoogle() {
const self = this;
this.afAuth.auth
.signInWithPopup(new firebase.auth.GoogleAuthProvider())
.then(res => {
self.closeDialog();
});
}
}
On successful response from Google OAuth, I see that closeDialog() is called. However, the dialog isn't closed. [I have no issues closing dialog as part of setTimeOut/UserAction]
Not sure it's related but had the same problem and I tracked it down to the fact that I had a form in my dialog and I was using ngModel for dual binding in my inputs but the object I was binding to was undefined.
Below, if that input is in the dialog, if
data.media.i18n.en.titleis undefined, there will be no exception in the console and the mdDialog will not close.So before opening my dialog I had to initialize that object correctly:
You can test that here: https://plnkr.co/edit/95atm4PIeKvyorVkcD0f?p=preview
That plnkr fails. If you want to correct it, define animal.name before opening the dialog.
Also, when it fails, you can see that there is no animation on the dialog.
Not sure it's your case as you didn't publish much code.