I cannot comprehend how DI can be used to provide a specific constructor argument in a component that i have imported. The NgbDatePicker contains a custom formatter interface (NgbDateParserFormatter), which, when implemented, can be passed in the constructor to the component to display custom date formats.
I am using the NgbDatePicker component as follows:
<input class="form-control" placeholder="yyyy-mm-dd" ngbDatepicker
name="dp-start" [(ngModel)]="startDate"
#dpStart="ngbDatepicker" id="dp-start">
If I wrapped the NgbDatePicker in my own component, then i could pass the custom NgbDateParserFormatter through my constructor and apply it. However, i do not wish to have a separate component.
How can i configure an external component such as the NgbDatePicker through DI from Angular 2?
The ng-bootstrap team still doesn't have a demo for this so here's how you can provide a custom formatter for your NgbDatePickers via your NgModule providers array.
Custom parse formatter will have a parse and a format function which are required. Parse is responsible for the internal model information being set and format handles display.
custom.formatter.ts
module.ts
Note that this is all based off of their own source code
Here's a Plunker