package. json
{
"dependencies": {
"moment-timezone": "^0.5.31"
},
"devDependencies": {
"moment": "^2.26.0"
}
}
tz-date-picker. js
const MomentTz = require('moment-timezone');
export default angular
.component('tzDatePicker', {
controller: function () {
this.MomentTz = MomentTz;
this.select = function (time_zone, self) {
selected_time_zone = time_zone;
if (this.dateTime instanceof moment) {
this.dateTime = this.MomentTz(this.dateTime);
this.dateTime.seconds(0);
}
if (this.dateTime instanceof this.MomentTz) {
this.dateTime.tz(time_zone.timeZone);
}
};
},
})
.name;
Почему мне нужно импортировать moment-timezone
, но moment
автоматически доступный? Есть ли способ получить доступный класс moment-timezone
внутри this.select = function () {};
, не назначая его компоненту?