0

here is my folder structure and i want to import PolicyDetail class to Policy.Service class how can i do that here im tired following code

in my Policy.Service class :

import { PolicyDetail } from '/App/Shared/PolicyDetail';

folder structure

App
 -- Shared/
         -  PolicyDetail.ts

 --Quote/
        -Services /
                  -- Policy.Service.ts
1
  • import { PolicyDetail } from 'App/Shared/PolicyDetail' Commented Feb 7, 2017 at 12:18

1 Answer 1

2

Imports are always relative to the current file's location. That means you have to specify how to get to PolicyDetail from Policy.Service. It would be something like this.

import { PolicyDetail } from '../../Shared/PolicyDetail';

Demistification:

  1. We start from the location of Policy.Service that being the Service folder.

  2. We go to the parent (../) and end up in the Quote folder.

  3. From here we go once again to the parent (../) and end up in the App folder.
  4. From here we have to go in to the shared folder (Shared/) and specify which file we want from it (PolicyDetail).
Sign up to request clarification or add additional context in comments.

2 Comments

thank you but i still could understand actually App folder inside the wwwroot folder so why i did not include the App folder to path ?
I amended my answer with an explanation of why the path looks like it does.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.