Eckig Material: Wie schließen Sie alle mat-Dialoge und süß-Warnungen auf logout

Wollte ich Nähe alle meine Dialogfeld (mat-Dialogfeld bootstrap-modals & sweet-alerts) auf logout im Winkel. Dies ist, wie es gemacht wurde in AngularJS (version 1.5):

function logout() {
  //hide $mdDialog modal
  angular.element('.md-dialog-container').hide();

  //hide any open $mdDialog modals & backdrop
  angular.element('.modal-dialog').hide();
  angular.element('md-backdrop').remove();

  //hide any open bootstrap modals & backdrop
  angular.element('.inmodal').hide();
  angular.element('.fade').remove();

  //hide any sweet alert modals & backdrop
  angular.element('.sweet-alert').hide();
  angular.element('.sweet-overlay').remove();
}

Wie kann ich dies in Eckige? Mit $('.mat-dialog-container') oder $('.inmodal') tut nicht geben mir eine option zu tun hide() oder close()

Ich habe versucht zu tun, aber ich wan ' T in der Lage, um die element-Referenz:

import { ElementRef, Injectable, ViewChild } from '@angular/core';
import { MatDialog, MatDialogContainer, MatDialogRef } from '@angular/material';

export class MyClass
{
  @ViewChild('.mat-dialog-container') _matDialog: ElementRef;
  @ViewChild('.mat-dialog-container') _matDialogRef:MatDialogRef<MatDialog>;

  constructor() { }

  function logout()
  {
    //access the dialogs here
  }
}
InformationsquelleAutor Sri7 | 2018-04-06
Schreibe einen Kommentar