导入服务的文件路径的正确语法是什么?我有一个数据服务想要导入到我的组件中,它的文件路径在这里:
C:\Users\jlz\Documents\Git\Pantheon\Ceto-www\src\app\services\ceto-data\data.service.ts
我的组件文件位于此处:
C:\Users\jlz\Documents\Git\Pantheon\Ceto-www\src\app\querypageheader\querypageheader.component.ts
我的导入语句如下所示:
import { DataService } from './data.service';
我尝试了各种不同的文件路径,但没有一个正确。我收到的错误是我的文件路径找不到 DataService。
最佳答案
将其更改为,
import { DataService } from './../services/ceto-data/data.service';
您可以简单地使用VSCode
,它会自动为您导入路径。
关于javascript - Angular 2 : import service file path not found,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/45720475/