1
我已經看到了angular.io上的目錄結構,但我不滿意他們提供的指導方針。通常我們可以在任何模塊中使用的服務和模型,請看看下面的結構角度目錄結構
app
|---modules
| |---account
| | |---list-account.component.ts|html|css
| | |---add-account.component.ts|html|css
| |---customer
| |---list-customer.component.ts|html|css
| |---add-customer.component.ts|html|css
|---services
| |---account.service.ts
| |---customer.service.ts
|---models
| |---account.model.ts
| |---customer.model.ts
我曾嘗試使用下面的結構,但在導入的打字稿文件的相對URL太不清楚。例如,如果我想在add-account.component
進口account.model
,import語句看起來像這樣
// ../../ looks so wierd, is it a good practise?
import { AccountModel } from '../../models/account.model';
// is it good practise to use absolute paths to import for typescript in angular?
import { AccountModel } from '~/models/account.model';
我想在所有的組件和服務已被重新用於重新使用我的模型。請給我建議一些好的目錄結構。任何幫助是極大的讚賞。
使用** **桶進口。與相對路徑相比,當您轉向生產時,絕對路徑引用總是很好 – Aravind