У меня есть константы, объявленные в конструкторе в моем файле .ts.Я хотел бы отобразить их значение в шаблоне.
Это хорошая практика?
РЕДАКТИРОВАТЬ:
import {Component, OnInit, Output} from '@angular/core';
import { NavController } from 'ionic-angular';
import {MemoryEditPage} from "../memory-edit/memory-edit";
@Component({
selector: 'page-memory-list',
templateUrl: 'memory-list.html',
})
export class MemoryListPage implements OnInit {
@Output() k_user: string;
@Output() type: MemoryType = MemoryType.memories;
constructor(
private auth: AuthService,
public navCtrl: NavController,
) {
const monthNames = ['Janvier','Février','Mars','Avil','Mai','Juin','Juillet','Août','Septembre','Octobre','Novembre','Décembre'];
const thisMonth = monthNames[(new Date()).getMonth()];
const dayNames = ['Lun','Mar','Mer','Jeu','Ven','Sam','Dim'];
const thisDay = dayNames[(new Date()).getDay() - 1];
const thisDate = (new Date()).getDate();
this.thisDay = thisDay;
this.thisDate = thisDate;
this.thisMonth = thisMonth;
}
}
Шаблон:
<ion-label no-margin text-uppercase color="white">{{thisMonth}}</ion-label>