@Optional dependency in Angular

Usage of @Optional (optional dependency), for example when LoginComponent is used as dialog or standalone.

  import { Optional } from '@angular/core';
 
  constructor(
    @Optional() private dialogRef: MatDialogRef<LoginComponent>,
    ) {  	
    ...
  }