如何缩短 import Angular 中的路径?

How to shorten path in import Angular?

有时我必须根据当前组件位置指定另一个 service/component 的完整路径,例如:

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

同意,不方便。

如何缩短这条通向美丽优雅的道路?

这可能是style. Consider restructuring your application to follow the LIFT原则的问题,这样你就可以快速定位代码,一目了然地识别代码,尽可能保持最扁平的结构,并尽量做到DRY。

为了尽可能保持文件夹结构平坦,请利用将应用程序拆分为模块的优势并利用 folders by feature

看看 here 文件夹结构的一个很好的例子。