title: Angular 2 Import Service into Component
body: <p>I am trying to import a service into a component that is in a different directory, but I keep getting a <code>cannot find module error</code> on the service import.</p>
  
  <p>directory structure:</p>
  
  <p><a href="https://i.stack.imgur.com/oShiw.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/oShiw.png" alt="enter image description here"></a></p>
  
  <p>//Component</p>
  
  <pre><code>import { Component, OnInit } from '@angular/core';
  import { AtmService } from '../services/atm.service';
  
  @Component({
    selector: 'app-atm-list',
    templateUrl: './atm-list.component.html',
    styleUrls: ['./atm-list.component.css']
  })
  export class AtmListComponent implements OnInit {
  
    atms: Array&lt;any&gt;;
  
    constructor(private atmService: AtmService) { }
  
    ngOnInit() {
  
      this.atmService.getAtms().subscribe{
        data =&gt; {
          this.atms = data;
        },
        error =&gt; console.error(error)
      };
    }
  
  }
  </code></pre>