Closed thejaff2 closed 7 years ago
Does work when using non-global options though (strange, since global format worked in 1.0.3):
<abp-datetime-picker model.bind="startdate" options.bind="{ format: 'YYYY-MM-DD' }" ></abp-datetime-picker>
in the latest code, I also refactored how I get the format
, it might have affected the global. I actually haven't tried to just use the format
in the Global config, that's a good point but I actually didn't think about that. Will have to revisit my code later.
Fixed the Global format, the custom options (in View or ViewModel) will have priority over the global options.
I definitely will have to look into adding unit testing for these, however that will have to wait since I'm going in vacation in a week.
By the way, I saw you using TypeScript, which I haven't worked with yet. Is there something to add in my plugin to cover both TypeScript/non-TypeScript? Do you have to use the type {any}
somewhere in your code because I'm not defining types or...? I'm just not familiar with it yet, any guidance would help. I might add that later if this could help anyhow.
It works now, great.
You dont have to add any typings for it to work with TypeScript, it is a bonus though. Writing large complex business applications should not be done with plain JavaScript (even TypeScript is a barely a good-enough solution imo).
main.ts:
.plugin('aurelia-bootstrap-datetimepicker', config => { config.options.format = 'YYYY-MM-DD'; }
view.ts:
<abp-datetime-picker model.bind="startdate" ></abp-datetime-picker>
viewmodel.ts:
this.startdate = new Date(2017, 3, 1);
Upon first load it shows this:![image](https://cloud.githubusercontent.com/assets/26161885/24993491/d3d39764-2026-11e7-89ad-1313ce1b95b3.png)
But when given focus it displays correctly:![image](https://cloud.githubusercontent.com/assets/26161885/24993511/edec26d4-2026-11e7-8cca-aea24b448ae6.png)
It also reverts back to the long format when trying to change it with keyboard, so it is not possible to enter date this way. My guess is that the binding should not trigger to use moment() until the input loses focus (ie when the user is finished writing)