Estou criando uma aplicacao sobre uma biblioteca aonde usuarios emprestam livros, no meu modulo de livros BookModule quero que tenha os components bookList.component e registerBook.component e ai meu AppModule importe o BookModule para usar os componentes dele. O problema e que quando faco isso da o seguinte erro "Can't bind to 'routerLink' since it isn't a known property of 'a'." Vou deixar o codigo dos componentes e modules aqui. bookList.component
import { Component, Inject } from "@angular/core";
import { Http } from "@angular/http";
@Component({
moduleId: module.id,
templateUrl: './bookList.component.html'
})
export class BookListComponent{
books: Object[] = [];
constructor(http: Http){
http
.get("http://localhost:52637/api/books")
.map(response => {
return response.json();
})
.subscribe(books => {
this.books = books;
}, error => console.log(error));
}
}
registerBook.coponent
import { Component } from "@angular/core";
@Component({
moduleId: module.id,
templateUrl: './registerBook.component.html'
})
export class RegisterBookComponent{}
app.routes
import { RouterModule, Routes } from "@angular/router";
import { AppComponent } from "./app.component";
import { BookModule } from "./book/book.module";
import { RegisterBookComponent } from "./book/registerBook.component";
import { BookListComponent } from "./book/bookList.component";
const appRoutes: Routes = [
{ path: 'book', component: RegisterBookComponent },
{ path: 'books', component: BookListComponent }
];
export const routing = RouterModule.forRoot(appRoutes);
BookModule
import { NgModule } from "@angular/core";
import { BookListComponent } from "./bookList.component";
import { RegisterBookComponent } from "./registerBook.component";
@NgModule({
declarations: [BookListComponent, RegisterBookComponent],
exports: [BookListComponent, RegisterBookComponent]
})
export class BookModule{}
AppModule
import { BrowserModule } from '@angular/platform-browser';
import { NgModule } from '@angular/core';
import { AppComponent } from './app.component';
import { BookModule } from "./book/book.module";
import { routing } from "./app.routes";
import { HttpModule } from "@angular/http";
import 'rxjs/add/operator/map';
@NgModule({
imports: [
BrowserModule, routing, HttpModule, BookModule
],
declarations: [
AppComponent
],
providers: [],
bootstrap: [AppComponent]
})
export class AppModule { }