Advertisement
aaa4Alex

Untitled

Sep 17th, 2020
1,872
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. import {Component, OnDestroy, OnInit} from '@angular/core';
  2. import {AccountDto} from '../dto/AccountDto';
  3. import {ActivatedRoute} from '@angular/router';
  4. import {AccountService} from '../account.service';
  5. import {Location} from '@angular/common';
  6. import {Subscription} from 'rxjs';
  7.  
  8. @Component({
  9.   selector: 'app-account-detail',
  10.   templateUrl: './account-detail.component.html',
  11.   styleUrls: ['./account-detail.component.css']
  12. })
  13. export class AccountDetailComponent implements OnInit, OnDestroy {
  14.   account: AccountDto;
  15.   subscription: Subscription;
  16.  
  17.   constructor(
  18.     private route: ActivatedRoute,
  19.     private accountService: AccountService,
  20.     private location: Location
  21.   ) {
  22.   }
  23.  
  24.   getAccount(): void {
  25.     const id = +this.route.snapshot.paramMap.get('id');
  26.     this.subscription = this.accountService.getOne(id).subscribe(account => this.account = account);
  27.  
  28.   }
  29.  
  30.  
  31.   ngOnInit(): void {
  32.     this.getAccount();
  33.   }
  34.  
  35.   ngOnDestroy(): void {
  36.     this.subscription.unsubscribe();
  37.   }
  38.  
  39.  
  40. }
  41.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement