I am currently developing a final Angular2 application with two modules:
- CoreModule: This module includes shared components and services.
- AppModule: The main module of the application.
AppModule:
/**
* Created by jamdahl on 9/21/16.
*/
// Imports
import {NgModule} from '@angular/core';
import {BrowserModule} from '@angular/platform-browser';
import {HttpModule} from '@angular/http';
import {FormsModule, ReactiveFormsModule} from '@angular/forms';
import {CoreModule} from '../core-module/core.module';
import {UserService, AuthService, AuthComponent} from '../core-module/core.module';
// Components
import {HomePageComponent} from './components/home-page.component';
@NgModule({
imports: [
BrowserModule,
HttpModule,
FormsModule,
ReactiveFormsModule,
CoreModule
],
declarations: [
AuthComponent,
HomePageComponent
],
providers: [
AuthService,
UserService
],
bootstrap: [
HomePageComponent
]
})
export class AppModule {}
CoreModule:
/**
* Created by jamdahl on 9/21/16.
*/
// Imports
import {NgModule} from '@angular/core';
import {BrowserModule} from '@angular/platform-browser';
import {HttpModule} from '@angular/http';
import {FormsModule, ReactiveFormsModule} from '@angular/forms';
// Class imports
import {User} from './classes/user.class';
import {Alert} from './classes/alert.class';
// Service imports
import {AuthService} from './services/auth.service';
import {UserService} from './services/user.service';
// Component imports
import {AuthComponent} from './components/auth.component';
import {SignInComponent} from './components/signin.component';
import {SignUpComponent} from './components/signup.component';
@NgModule({
imports: [
BrowserModule,
HttpModule,
FormsModule,
ReactiveFormsModule
],
declarations: [
AuthComponent,
SignInComponent,
SignUpComponent
],
providers: [],
exports: [
User,
Alert,
AuthService,
UserService,
AuthComponent
]
})
export class CoreModule {}
However, when I attempt to run it, I encounter the following errors:
ERROR in ./src/view/app-module/app.module.ts (11,9): error TS2305: Module '"/Users/jamdahl/Web/Web-Scratch/Angular2-Express-Mongoose/src/view/core-module/core.module"' has no exported member 'UserService'.
ERROR in ./src/view/app-module/app.module.ts (11,22): error TS2305: Module '"/Users/jamdahl/Web/Web-Scratch/Angular2-Express-Mongoose/src/view/core-module/core.module"' has no exported member 'AuthService'.
ERROR in ./src/view/app-module/app.module.ts (11,35): error TS2305: Module '"/Users/jamdahl/Web/Web-Scratch/Angular2-Express-Mongoose/src/view/core-module/core.module"' has no exported member 'AuthComponent'.
Could someone provide insight into why this setup is not functioning as expected? My aim is to define components and services in a module for reuse in other modules that will be created. I need to find the correct approach to accomplish this...
Thank you in advance for any assistance!