File

app/dxa/dxa-entity/views/news-items/news-items-main/news-items-main.component.ts

Index

Properties

Properties

company_info
company_info: string
Type : string
imageAlt
imageAlt: string
Type : string
imageUrl
imageUrl: string
Type : string
ingress
ingress: string
Type : string
news_date
news_date: Date
Type : Date
news_text
news_text: string
Type : string
press_contacts
press_contacts: string
Type : string
time_zone
time_zone: any
Type : any
title
title: string
Type : string
import { OnInit, Component, Input, ChangeDetectionStrategy, HostBinding } from '@angular/core';
import { UtilService } from 'src/app/core/services/util-service/util.service';
import { ConstantsService } from 'src/app/shared/constants/constants.service';
interface NewsItems {
	title: string;
	news_date: Date;
	time_zone: any;
	ingress: string;
	news_text: string;
	press_contacts: string;
	company_info: string;
	imageUrl: string;
	imageAlt: string;
}

@Component ({
	selector: 'article[news-items-main]',
	templateUrl: './news-items-main.component.html',
	styleUrls: ['./news-items-main.component.scss'],
	changeDetection: ChangeDetectionStrategy.OnPush
})
export class NewsItemsMainComponent implements OnInit {

	@Input() entity;
	data;

	@HostBinding('class') get class() { return 'col-md-8 space-between'; }
	@HostBinding('attr.role') get role() { return 'article'; }

	constructor(
		private util: UtilService,
		private constants: ConstantsService
	) {}

	ngOnInit() {
		const tz = this.util.extract(this.entity, 'Timezone') || '';
		this.data = this.parseJSON(this.entity);
	}
	public parseJSON(entity): NewsItems {
		const tz = this.util.extract(entity, 'Timezone') || '';
		const title = this.util.extract(entity, 'Title') || '';
		const news_date = this.util.extract(entity, 'Newsdate') || '';
		const time_zone = this.constants.getTimezone(tz);
		const ingress = this.util.extract(entity, 'Ingress') || '';
		const news_text = this.util.extract(entity, 'Newstext') || '';
		const press_contacts = this.util.extract(entity, 'Presscontacts') || '';
		const company_info = this.util.extract(entity, 'Companyinfo') || '';
		const imageUrl = this.util.extract(entity, 'Image', [0], 'Image', 'Url') || '';
		const imageAlt = this.util.extract(entity, 'Image', [0], 'Image', 'Assetmetadata', 'Cmsdescription') || '';

		const parsed = {
			title: title,
			news_date: news_date,
			time_zone: time_zone,
			ingress: ingress,
			news_text: news_text,
			press_contacts: press_contacts,
			company_info: company_info,
			imageUrl: imageUrl,
			imageAlt: imageAlt
		};
		return parsed;
	}

}

result-matching ""

    No results matching ""