I am working on Angular2. As we know we need to configure all providers
, components
, services
in the main module. It may be the case where we have a large number of components
and manually configuring it. For instance, consider the following module
import { NgModule } from '@angular/core';
import { FormsModule } from '@angular/forms';
import { BrowserModule } from '@angular/platform-browser';
import { HttpModule } from '@angular/http';
import { AppComponent } from './app.component';
import { GoogleSigninComponent } from ./auth/google.login.component';
import { ApiEndpoints } from './api.endpoints';
// Providers
import { AuthService } from './auth/auth.service';
import { AppRoutingModule } from './route';
import { ExpenseComponent } from './expense/expense.component';
import { ExpenseService } from './expense/expense.service';
import { GroupService } from './group/group.service';
import {GroupUserService} from './group/group-user.service';
import {MainGroupComponent, SaveGroupComponent, GroupListComponent } from './group/group.components';
import {GroupUsersComponent,AddGroupUserComponent} from './group/group- user.component';
import {HelperService } from './helper.service';
import {SearchUserComponent} from './user/users.component';
import {UserService} from './user/users.service';
@NgModule({
imports: [BrowserModule, HttpModule, BrowserModule, AppRoutingModule, FormsModule],
declarations: [AppComponent, GoogleSigninComponent,
ExpenseComponent, SaveGroupComponent, GroupListComponent, GroupUsersComponent,
MainGroupComponent,AddGroupUserComponent,SearchUserComponent],
bootstrap: [AppComponent],
providers: [AuthService, ApiEndpoints, ExpenseService,
GroupService,GroupUserService,HelperService,UserService]
})
I need to configure the same in routes
and somewhat cubersome
What will be the right way to configure this large number of components without much copy-pasting?
Also, I believe there should be multiple modules. What's your suggestion or the right way to do it?