title: Dynamically Creating Mat Dialog Config
body: <p>I provide <code>MAT_DIALOG_DEFAULT_OPTIONS</code> in <code>app.module.ts</code> to create global defaults for <code>MatDialog</code> dialogs:</p>
  
  <pre><code>function matDialogProviderFactory() {
    const matDialogConfig: MatDialogConfig = {/* presets */};
  
    if (/* some condition */) {
      matDialogConfig.panelClass = 'a-class';
    }
  
    return matDialogConfig;
  }
  
  @NgModule({
    ...,
    providers: [
      {
        provide: MAT_DIALOG_DEFAULT_OPTIONS,
        useFactory: matDialogProviderFactory,
      }
    ],
  })
  
  </code></pre>
  
  <p>My goal is to evaluate the condition in <code>matDialogProviderFactory()</code> every time a dialog is created so I can conditionally add a class. However, the function is run only once at the start. How can I run <code>matDialogProviderFactory()</code> every time a dialog is created? Or, how else can I achieve my goal?</p>