Snorlax
Snorlax

Reputation: 4745

Angular2: import service file path not found

What is the correct syntax for my file path to import my service? I have a data service that I want to import into my component, it's file path is here:

C:\Users\jlz\Documents\Git\Pantheon\Ceto-www\src\app\services\ceto-data\data.service.ts

My component file is located here:

C:\Users\jlz\Documents\Git\Pantheon\Ceto-www\src\app\querypageheader\querypageheader.component.ts

My import statement looks like this:

import { DataService } from './data.service';

I've tried various different file paths, but none came out correct. The error I get is my file path can't locate DataService.

Upvotes: 2

Views: 563

Answers (1)

Sajeetharan
Sajeetharan

Reputation: 222582

Change it as,

import { DataService } from './../services/ceto-data/data.service';

You can simply use VSCode, it will automatically import the path for you.

Upvotes: 3

Related Questions