在 Angular 中使用相对路径:找不到模块
Using realative paths in Angular: Cannot find module
你好,
我正在尝试从 Angular 中的不同组件导入 class。但我不断收到错误错误:
Cannot find module './app/_services/modal.service' or its corresponding type declarations.
我的导入语句如下所示
import {ModalService} from './app/_services/modal.service';
我的目录树看起来像这样,我正在尝试从聊天组件转到 _services:
- 来源
- /应用程序
- /_服务
- /聊天应用
- /chat/chatcomponent.ts
您应该从 src 文件夹开始导入路径 src/app/_services/modal.service
或者您应该向后移动两个文件夹以到达 _services 文件夹 ../../_services/modal.service
你好, 我正在尝试从 Angular 中的不同组件导入 class。但我不断收到错误错误:
Cannot find module './app/_services/modal.service' or its corresponding type declarations.
我的导入语句如下所示
import {ModalService} from './app/_services/modal.service';
我的目录树看起来像这样,我正在尝试从聊天组件转到 _services:
- 来源
- /应用程序
- /_服务
- /聊天应用
- /chat/chatcomponent.ts
- /应用程序
您应该从 src 文件夹开始导入路径 src/app/_services/modal.service
或者您应该向后移动两个文件夹以到达 _services 文件夹 ../../_services/modal.service