angular - Unable to route from on page component to another page -


i new in angular 2,i using ng2-admin template in angular 2.0.0 version. want route pages component if user logged in route dashboard page.currently using "route.navigate(['dashboard'])" after call function gives me error undefined routes. following component side code: enter image description here

my module.ts file enter image description here

my login routing component : enter image description here

and main routing component : enter image description here

please me out, thanks

you have import { routermodule, routes } '@angular/router'; , have declare routes below in app.ts or main.ts:

const routes: routes = [   { path: '', redirectto: '/dashboard', pathmatch: 'full' },   { path: 'dashboard',  component: dashboardcomponent }, ]; @ngmodule({   imports: [ routermodule.forroot(routes) ],   exports: [ routermodule ] }) 

then can use routes in corresponding component below:

this.router.navigate(['/dashboard']); 

adding new function:

gotodashboard() {     console.log("coming");     console.log(this);     this.router.navigate(['/dashboard']); } 

and call in response => {this.gotocrises()}.


Comments

Popular posts from this blog

asynchronous - C# WinSCP .NET assembly: How to upload multiple files asynchronously -

aws api gateway - SerializationException in posting new Records via Dynamodb Proxy Service in API -

asp.net - Problems sending emails from forum -