John Churchley
John Churchley

Reputation: 444

Separating out component references into separate files in Angular 2

Is it possible to create a typescript file of all component references to use in different modules like the app module and app-routing module to avoid duplication?

import { AppComponent } from './app.component';
import { HeaderComponent } from './components/header.component';
import { BreadcrumbComponent } from'./components/breadcrumb.component';

Up want to just be able to do something like this

import from '/components'

Upvotes: 1

Views: 123

Answers (1)

bluray
bluray

Reputation: 1953

You should create file .components/index.ts

index.ts

export * from './components/header.component'
export * from './components/breadcrumb.component'

Now you can use as:

import {HeaderComponent,BreadcrumbComponent } from './components'

Upvotes: 1

Related Questions