0

Sometimes I have to specify the full path to another service/component based on current component location like:

import {LocalService} from '../../../_services/LocaleService';

To agree that it is not convenient.

How to shorten this path to more beauty and elegant?

POV
  • 11,293
  • 34
  • 107
  • 201
  • See this question [Angular2 - root relative imports](https://stackoverflow.com/questions/34614818/angular2-root-relative-imports) – Richard Matsen Nov 13 '17 at 23:26
  • You can add the paths to you tsconfig. See this. [How to use paths in tsconfig.json answer.](https://stackoverflow.com/questions/43281741/how-to-use-paths-in-tsconfig-json#answer-43330003) – ttugates Nov 13 '17 at 23:41

1 Answers1

0

This may be a matter of style. Consider restructuring your application to follow the LIFT principle such that you can Locate code quickly, Identify the code at a glance, keep the Flattest structure you can, and Try to be DRY.

To keep the folder structure as flat as possible, take advantage of splitting your application into modules and utilize folders by feature.

Take a look here for a good example of folder structure.

Michael Kang
  • 52,003
  • 16
  • 103
  • 135