my routing in angular2 apps works well. going make routelink based on this:
here routing:
const routes: routerconfig = [ { path:'home' , component: formcomponent }, { path:'about', component: aboutcomponent }, { path:'**' , component: formcomponent } ];
and here links made:
<ul class="nav navbar-nav item"> <li> <a routerlink='/home' routerlinkactive="active">home</a> </li> <li> <a routerlink='/about' routerlinkactive="active">about this</a> </li> </ul>
i expect that, when click on them navigates respected component, not perform anything?
the code showing there absolutely correct.
i suspect problem not importing routermodule (which routerlink declared) module uses template.
i had similar problem , took me time solve step not mentioned in documentation.
so go module declares component template , add:
import { routermodule } '@angular/router';
then add modules imports e.g.
@ngmodule({ imports: [ commonmodule, routermodule ], declarations: [mytemplatescomponent] }) export class mytemplatesmodule { }
Comments
Post a Comment