Tuesday, January 9, 2018

how to use mydatepicker in an Angular 4 app

You set up something like this on the template side of a component:

<my-date-picker id="startStartDate" placeholder="MM/DD/YYYY"
      (dateChanged)="someDate=$event.date; doSomething()" [options]="myOptions">
</my-date-picker>

 
 

We set a not-quite-date on the TypeScript side with the assignment to "someDate" herein and then turn around and call the doSomething() method too. Options may just be like:

private myOptions:IMyOptions = {
   dateFormat: 'mm/dd/yyyy',
   firstDayOfWeek: 'su'
};

 
 

Note that $event.jsdate instead of $event.date will give you a traditional JavaScript date back.

No comments:

Post a Comment