簡體   English   中英

在 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';

我的目錄樹看起來像這樣,我正在嘗試將 go 從聊天組件到 _services:

  • 源代碼
    • /應用程序
      • /_服務
      • /聊天應用
        • /chat/chatcomponent.ts

您應該從 src 文件夾src/app/_services/modal.service開始導入路徑,或者您應該向后移動兩個文件夾以到達 _services 文件夾../../_services/modal.service

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM