I am trying to format a date string inside a t-params.bind statement but every time I try to do so I just get errors saying that I am missing a comma which I don’t think I am. I’ve tried using a comma too and that gets rid of the error message but then I don’t get my formatted date like I want.
My html code looks almost like this (can’t share company code so it’s somewhat modified):
t-params.bind="{value: 'dateString | dateFormat: 'LLL'}"
I don’t know what to do, I can’t ask anyone for help at my company atm because they’re all in meetings.
1 Like
It’s not missing a comma but a singlequote after dateString. Moreover I’m not sure whether you can use a valueconverter inside the params attribute. Is there a way that you format the dateString in your VM and assign that? E.g dateString might as well be a getter and inside you just perform the formatting plus computedFrom decorator so it doesn’t do unnecessary dirtyWatching
1 Like
Hmm, well I tried adding in that missing singlequote but that didn’t help, unfortunately.
I’m still pretty new to Aurelia and our workflow here, by “VM” do you mean virtual machine?
There may be a way for me to format the date in our typescript but I am not sure.
1 Like
Well then welcome to the board
With VM I was referring to the ViewModel, so the code file that goes together with your View (your-component.ts/html).
In there you have somewhere your property dateString
you’re binding to from the view. So instead try something like this perhaps
export class YourComponent {
public get formattedDateString() {
// return formatted string here
}
}
2 Likes
I finally got in touch with a co-worker and he was able to help me out. Turns out that we had to change some configuration settings in Aurelia and mess with the translations as well.
In our translation file we had a key-value pair that looked kinda like this:
“exampleKey”: “Text: {{value}}”
and we only had to change it to:
“exampleKey”: “Text: {{value, dateFormat:LLL}}”
and voilá, it works
1 Like
ahh ok, and that is where that ominous comma is missing glad you got it figured.
1 Like