So I'm new to VueJs and I'm trying to create a global directive to format date using moment.js. My problem is that the directive is not getting triggered. Idk if I'm calling it right or not.
dateFormat.js
import Vue from "vue";
import moment from "moment";
Vue.directive("formatdate", function(value) {
if (value) {
return moment(String(value)).format("MM/DD/YYYY hh:mm");
}
});
itemList.vue
<span v-formatdate>{{ item.date_added }}</span>