MAT_RADIO_DEFAULT_OPTIONS for all project

Viewed 255

Where I can point the MAT_RADIO_DEFAULT_OPTIONS to don't write it in each component? For example a color- I need 'primary', not 'accent' (accent is default color's value)

@Component({
  selector: 'app-diagnoses-dialog',
  templateUrl: './diagnoses-dialog.component.html',
  styleUrls: ['./diagnoses-dialog.component.scss'],
  providers: [{
    provide: MAT_RADIO_DEFAULT_OPTIONS,
    useValue: { color: 'primary' },
  }]
})
1 Answers

You can add it to app component module to affect globally.

import {NgModule} from '@angular/core';
import {MatRadioModule, MAT_RADIO_DEFAULT_OPTIONS} from '@angular/material/radio';


@NgModule({
  exports: [
    MatRadioModule,
  ],
  providers: [{
    provide: MAT_RADIO_DEFAULT_OPTIONS,
    useValue: { color: 'primary' },
}]

})
export class AppModule {}
Related