import { Component, OnInit } from '@angular/core'; import { ActivatedRoute } from '@angular/router'; import { AccountService } from '../accounts-services'; import { DefineAccountViewModel } from '../accounts.class'; import { LocalService } from '../../../_services/local.service'; @Component({ selector: 'app-account-dtl-view', templateUrl: './account-dtl-view.component.html', }) export class AccountDtlViewComponent implements OnInit { public defineAccount = new DefineAccountViewModel(); constructor(private activatedRoute: ActivatedRoute, public _accountService: AccountService, private _localService: LocalService) { } ngOnInit() { this.activatedRoute.queryParams.subscribe(params => { const accId = params['id']; if (accId != null) { this.getAccount(accId); } }); } public getAccount(id: number) { this._accountService.getAccountById(id).subscribe((res: any) => { if (res) { this.defineAccount = res.acc; } }, err => { }); } }