Formatter support is not working
See original GitHub issueIssue 1:
Use case: a date slider (data model is UNIX time in milliseconds)
<nouislider style="margin: 80px;"
(change)="change()"
[min]="1483228800000"
[max]="1485820800000"
[step]="3600000"
[(ngModel)]="model"
[format]="formatter"
[tooltips]="true"></nouislider>
model: number = 1484611200000;
formatter: NouiFormatter = {
from(value: string): number {
console.log('from', value);
return Date.parse(value);
},
to(value: number): string {
console.log('to', value);
return new Date(value).toISOString();
}
};
change(): void {
console.log(this.model);
}
This example is not working.
Very odd: If you change model: number = 1484611200000
to model: string = '2017-01-17T00:00:00'
, then the slider seems to be working but the model
will not be updated.
Issue 2:
<nouislider style="margin: 80px;"
(change)="change()"
[min]="0"
[max]="9"
[step]="3"
[(ngModel)]="model"
[format]="formatter"
[tooltips]="true"></nouislider>
model: number = 6;
formatter: NouiFormatter = {
from(value: string): number {
console.log('from', value);
return Number(value);
},
to(value: number): string {
console.log('to', value);
return '#' + value;
}
};
change(): void {
console.log(this.model);
}
In this example the model
will not be updated. The from()
method is called once with a number
value (the model
value) and will be never called with a string
value. The correct from()
method should be:
from(value: string): number {
console.log('from', value);
return Number(value.slice(1,2));
}
but this is not working.
Issue Analytics
- State:
- Created 7 years ago
- Comments:9 (1 by maintainers)
Top Results From Across the Web
Black does not support "Format Selection" command
In my situation (select black as the Python Formatting Provider in VS Code Settings), I encountered this warning everytime when I pasting ...
Read more >formatter:off doesn't seem to be working
formatter:off doesn't seem to be working Follow. First, I definitely did enable: "Enable formatter markers in comments" option in "Settings | ...
Read more >"Cannot play back the file. The format is not supported. (Error ...
Cause. This issue may occur for one or more of the following reasons: One or more Windows Media Player files are missing or...
Read more >Common Problems with Formatter - Zapier Help
My Formatter step is not changing my dataAfter you've set up and tested your Formatter step, remember to map the output of the...
Read more >Format on Save (prettier) stopped working with latest update
Same thing happened to me just now. I set prettier as the Default Formatter in Settings and it started working again. My Default...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
@tb this works:
@nourhansaied I tested my code from above (https://github.com/tb/ng2-nouislider/issues/50#issuecomment-274765222) with Angular 5.2.10, ng2-nouislider 1.7.7, nouislider 11.1.0 and typescript 2.8.3 and it still works as expected…