Reputation: 2360
I'm using angular cli, and want to configure my import paths, like
import { NgModule } from '@angular/core';
so I don't write
import { NgModule } from '../../../node_modules/@angular/core';
What's the way to make my own default paths? so I can import my service like this for example
import { MyService } from '@services';
Upvotes: 1
Views: 348
Reputation: 1264
In tsconfig.json, you can configure TypeScript compiler like this:
"baseUrl": "./src",
"paths": {
"@Services/*": [
"app/services-folder/*" //All services files inside this services-folder
]
}
Then you can use your services
import { MyService } from '@Services/my.service'; //my.service.ts inside services-folder
Upvotes: 3