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
以下の構造を見てみたがtypescriptです内のファイルをインポート中に相対URLがあまりにも不明でください。 。例えば、私はadd-account.component
でaccount.model
をインポートする場合、インポート文は、私は、すべてのコンポーネントとサービスを再使用する必要があるの私のモデルを再利用したいこの
// ../../ 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