简体   繁体   中英

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.

Change it as,

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

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM