javascript - when component complete render then change route in angular 2 -


i have whatsnew component , route config:

@routeconfig([      { path: '/whatsnew', name: 'whatsnew', component: whatsnew },  ]) 

i'm in other route , component. problem want whatsnew rendered, route change , navigate whatsnew. don't want user see rendering page, how in angular 2?

you can implement canactivate lifecycle callback. way can either return promise completes true when call server returns going route fine or redirect route.

one problem canactivate decorator , di doesn't support decorators need reference service make server call.

this comment contains link plunker demonstrates how di can used canactivate

there few issues lifecycle callbacks don't wait promise resolve before continue navigation. don't remember if applies canactivate. there again new router on way , unlikely issues fixed old routers.


Comments

Popular posts from this blog

wordpress - (T_ENDFOREACH) php error -

Export Excel workseet into txt file using vba - (text and numbers with formulas) -

Using django-mptt to get only the categories that have items -