import { Component, OnInit } from '@angular/core'; import { ActivatedRoute } from '@angular/router'; import { ExpenseServices } from '../../expense-services'; import { ExpenseMastModel } from '../../expense-class'; import { NotificationService } from '../../../../_services/notification.service'; import { LocalService } from '../../../../_services/local.service'; @Component({ selector: 'app-sim-exp-dtl', templateUrl: './sim-exp-dtl.component.html', }) export class SimExpDtlComponent implements OnInit { public mast: any; constructor( private activatedRoute: ActivatedRoute, public _expenseServices: ExpenseServices, public _notificationService: NotificationService, private _localService: LocalService ) { } ngOnInit() { this.activatedRoute.queryParams.subscribe(params => { const accId = params['id']; if (accId != null) { this.getExpenseDtl(accId); } }); } public getExpenseDtl(e) { this._expenseServices.getExpDtl(e).subscribe((res: any) => { if (res) { console.log(res); // this.mast = new ExpenseMastModel(); this.mast = res; this.mast.UptoDate = new Date(res.UptoDate); this.mast.CreationDate = new Date(res.CreationDate); this.mast.BillFromDate = new Date(res.BillFromDate); this.mast.Items = res.Items; if (this.mast.Items !== undefined && this.mast.Items > 0) { res.Items.forEach(rec => { let exists = this.mast.Items.find(x => x.Id === rec.Id); if (exists === undefined) { this.mast.Items.push(rec); } }); } else { this.mast.Items = res.Items; } } }, err => { this._notificationService.notify('danger', err.error); }); } }