title: How to get data from service based from id?
body: <p>I dont know how to get data from service based on id in route on angular and need some help</p>
  <p>this is my account.service.ts</p>
  <pre><code>import { Observable } from &quot;rxjs&quot;;
  
  export class AccountsService {
    
    
      accounts = [
          {
            id: 1,
            name: 'Master Account',
            age: 23,
            status: 'active'
          },
          {
            id: 2,
            name: 'Testaccount',
            age: 23,
            status: 'inactive'
          },
          {
            id: 3,
            name: 'Hidden Account',
            age: 23,
            status: 'unknown'
          }
        ];
        
    }
  
        
        getData(id: string) {
          
        }
  }
  
  </code></pre>
  <p>This is my  component, in this part I can get the id but I don't know to get data from array in service based this id</p>
  <pre><code>import { Component, OnInit } from '@angular/core';
  import { ActivatedRoute } from '@angular/router';
  import { AccountsService } from 'src/app/account.service';
  
  @Component({
    selector: 'app-detail-card',
    templateUrl: './detail-card.component.html',
    styleUrls: ['./detail-card.component.css']
  })
  export class DetailCardComponent implements OnInit {
  
    constructor(
      private route:ActivatedRoute,
      private accountService:AccountsService
    ) { }
  
    ngOnInit(): void {
      this.getData()
    }
  
    getData(){
      const cardId = this.route.snapshot.paramMap.get('id');
    }
  
  }
  </code></pre>