Open andreyRybchuk opened 5 years ago
Any updates on this matter? This is a great and easy to use component. But, this issue is the only thing preventing me from using this component.
Nice job with this library. It's unfortunately unusable for many/most applications if you cannot use this component with an initial value. Edit mode exists in forms you know... CRUD. You support only C (and D).
setValue methods on the parent and the children please.
I copied the project and adopted it to my needs . Thanks. I use moment.js, so adding that dep is not an issue for me.
@Input('value')
set _value(val: number) {
this.setValue(val);
}
public setValue(value: number): void {
setTimeout(() => {
// @ts-ignore
let duration = moment.duration(value, this.unit + 's');
this.units.toArray().forEach(element => {
switch (element.name.toLocaleLowerCase()) {
case "year":
element.setValue(duration.years())
break;
case "month":
element.setValue(duration.months())
break;
case "week":
element.setValue(duration.weeks())
break;
case "day":
element.setValue(duration.days())
break;
case "hour":
element.setValue(duration.hours())
break;
case "minute":
element.setValue(duration.minutes())
break;
case "second":
element.setValue(duration.seconds())
break;
case "millisecond":
element.setValue(duration.milliseconds())
break;
}
});
})
@stnor if using moment is solving this issue. please open a PR and i will add that
Is it possible to set time by default, not 0? For example 2h23m.