I have Angular 2 (version 2.0.0 - final) application created using angular-cli.
When I create the component and add it to the AppModule declarations array, all this is good, it works.
I decided to separate the components, so I created a TaskModule and a TaskCard component. Now I want to use TaskCard in one of the AppModule components ( Board component).
AppModule:
import { BrowserModule } from '@angular/platform-browser'; import { NgModule } from '@angular/core'; import { FormsModule } from '@angular/forms'; import { HttpModule } from '@angular/http'; import { AppComponent } from './app.component'; import { BoardComponent } from './board/board.component'; import { LoginComponent } from './login/login.component'; import { MdButtonModule } from '@angular2-material/button'; import { MdInputModule } from '@angular2-material/input'; import { MdToolbarModule } from '@angular2-material/toolbar'; import { routing, appRoutingProviders} from './app.routing'; import { PageNotFoundComponent } from './page-not-found/page-not-found.component'; import { UserService } from './services/user/user.service'; import { TaskModule } from './task/task.module'; @NgModule({ declarations: [ AppComponent, BoardComponent,// I want to use TaskCard in this component LoginComponent, PageNotFoundComponent ], imports: [ BrowserModule, FormsModule, HttpModule, MdButtonModule, MdInputModule, MdToolbarModule, routing, TaskModule // TaskCard is in this module ], providers: [UserService], bootstrap: [AppComponent] }) export class AppModule { }
TaskModule:
import { NgModule } from '@angular/core'; import { TaskCardComponent } from './task-card/task-card.component'; import { MdCardModule } from '@angular2-material/card'; @NgModule({ declarations: [TaskCardComponent], imports: [MdCardModule], providers: [] }) export class TaskModule{}
The whole project is available at https://github.com/evgdim/angular2 (kanban-board folder)
What am I missing? What do I need to do to use TaskCardComponent in BoardComponent ?
angular typescript angular-module
Evgeni Dimitrov Sep 20 '16 at 18:55 2016-09-20 18:55
source share