Files
we_bstly-web/src/app/utils/html/html.component.ts
T
2022-01-21 22:38:31 +01:00

35 lines
1001 B
TypeScript

import { Component, OnInit, Input } from '@angular/core';
import { HttpClient, HttpHeaders } from '@angular/common/http';
import { I18nService } from './../../services/i18n.service';
@Component({
selector: 'app-html',
templateUrl: './html.component.html',
styleUrls: [ './html.component.scss' ]
})
export class HtmlComponent implements OnInit {
htmlTemplate: any;
locale: String;
@Input() template;
constructor(private i18n: I18nService, private httpClient: HttpClient) {
this.locale = this.i18n.getLocale();
}
ngOnInit(): void {
const headers = new HttpHeaders()
.set('content-type', 'text/html');
this.httpClient.get(
'./assets/templates/' + (this.locale ? this.locale + "/" : "") + this.template + ".html",
{
headers: headers,
responseType: 'text'
}).subscribe({
next: (response) => this.htmlTemplate = response
});
}
}