I need to display the date format depending on saved settings. I call axios to check saved date format:
axios
.get('/api/user/')
.then(response => (this.date_format = response.data.dateformat))
Then I added filters:
filters: {
moment: function (date) {
return moment(date).format(this.date_format);
}
},
And display it in HTML:
<p class="card-title"> Date of Birth:
<span[[dob | moment]]</span>
</p>
If I display [[data_format]] it shows correctly "DD/MM/YYYY". But when I try to console.log(this.date_format) console shows Undefined. How to replace FormatNeeded in return moment(date).format(FormatNeeded); with this.date_format?