// @ngInject
export default (SettingsSvc: SettingsSvc) =>
function dateFilter(input: string, format: string) {
if (!format) {
format = SettingsSvc.DateFormat
}
const momentDate = moment(input, format.replace('dd', 'DD'))
return momentDate.format('dddd, MMMM, Do YYYY')
}
Compiled output:
Object.defineProperty(exports, "__esModule", { value: true });
exports.default = function (SettingsSvc) {
return function dateFilter(input, format) {
if (!format) {
format = SettingsSvc.DateFormat;
}
var momentDate = moment(input, format.replace('dd', 'DD'));
return momentDate.format('dddd, MMMM, Do YYYY');
}
};
All is fine if we use 'ngInject' inside the arrow function:
export default (SettingsSvc: SettingsSvc) => {
'ngInject'
return function dateFilter(input: string, format: string) {
if (!format) {
format = SettingsSvc.DateFormat
}
const momentDate = moment(input, format.replace('dd', 'DD'))
return momentDate.format('dddd, MMMM, Do YYYY')
}
}
Object.defineProperty(exports, "__esModule", { value: true });
exports.default = ["SettingsSvc", function (SettingsSvc) {
'ngInject';
return function dateFilter(input, format) {
if (!format) {
format = SettingsSvc.DateFormat;
}
var momentDate = moment(input, format.replace('dd', 'DD'));
return momentDate.format('dddd, MMMM, Do YYYY');
}
}];
I prefer the comment syntax as it can be removed after ngAnnotate has done its job. Any thoughts? Comment syntax works in other instances (export default class, for example)
Using TypeScript 1.7.5. Uncompiled output:
Compiled output:
All is fine if we use
'ngInject'
inside the arrow function:I prefer the comment syntax as it can be removed after ngAnnotate has done its job. Any thoughts? Comment syntax works in other instances (
export default class
, for example)