angular - No provider for RouterOutletMap! in angular2 app -


i trying make routing angular2 app. have seen many questions this , this none of them helped me.

here app.route.ts:

import { providerouter, routerconfig } '@angular/router'; import {formcomponent} './form.component'; import {aboutcomponent} './about-this.component';  const routes: routerconfig = [     { path:'home' , component: formcomponent  },     { path:'about', component: aboutcomponent },     { path:'**'   , component: formcomponent  } ];  export const approuterproviders = [   providerouter(routes) ] 

and here root component:

import { router_directives, router } '@angular/router'; import { component } '@angular/core'; import {navbarcomponent} './shared/navbar.component'; import {approuterproviders} './app.routes'   @component({   moduleid: module.id,   selector: 'app-root',   templateurl: 'app.component.html',   styleurls: ['app.component.css'],   directives:[navbarcomponent,router_directives],   providers: [approuterproviders] })  export class appcomponent {      title = "here root!";   } 

and in temple is(app.component.html):

<router-outlet></router-outlet> 

as can see, have used ./app.routes route provider. result, expect, when use http://localhost:4200/home brings form component, not happen. also, there no error in console. going wrong?

update: also, bootstraped app main.ts :

import { bootstrap }  '@angular/platform-browser-dynamic'; import {appcomponent} './app.component'; import {approuterproviders } './app.routes';  bootstrap(appcomponent,[approuterproviders] ); 

the router needs provided in bootstrap

bootstrap(appcomponent, [approuterproviders]) 

Comments

Popular posts from this blog

Spring Boot + JPA + Hibernate: Unable to locate persister -

go - Golang: panic: runtime error: invalid memory address or nil pointer dereference using bufio.Scanner -

c - double free or corruption (fasttop) -