Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import {Component, OnDestroy, OnInit} from '@angular/core';
- import {AccountDto} from '../dto/AccountDto';
- import {ActivatedRoute} from '@angular/router';
- import {AccountService} from '../account.service';
- import {Location} from '@angular/common';
- import {Subscription} from 'rxjs';
- @Component({
- selector: 'app-account-detail',
- templateUrl: './account-detail.component.html',
- styleUrls: ['./account-detail.component.css']
- })
- export class AccountDetailComponent implements OnInit, OnDestroy {
- account: AccountDto;
- subscription: Subscription;
- constructor(
- private route: ActivatedRoute,
- private accountService: AccountService,
- private location: Location
- ) {
- }
- getAccount(): void {
- const id = +this.route.snapshot.paramMap.get('id');
- this.subscription = this.accountService.getOne(id).subscribe(account => this.account = account);
- }
- ngOnInit(): void {
- this.getAccount();
- }
- ngOnDestroy(): void {
- this.subscription.unsubscribe();
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement