export const FormatDate = new InjectionToken('FormatDate');
...
@Component({
selector: '...',
templateUrl: '...',
styleUrls: ['...'],
providers: [{ provide: FormatDate, useValue: 'MM.yyyy' }]
})
export class DatePicker {
@Input() format: string
...
}
I want to dynamically provide 'FormatDate' based on input 'format' parameter. If format === 'short' then useValue: 'MM.yy'. If format === 'long' then useValue: 'MM.yyyy'. Is that possible?