angular - ngAfterViewInit dosn't work -
//notes module //////////// const notesroutes: routes = [ { path: 'notes', component: notescomponent, children: [{ path: 'detail', component: notesdetailcomponent }, { path: '', redirectto: 'page1', pathmatch: 'full' }] } ]; ////////////// import { component, oninit, viewchild} '@angular/core'; ... export class notescomponent{ ngafterviewinit() { console.log('notes.location ', window.location); } } /////////////// import { component, oninit, viewchild} '@angular/core'; ... export class notesdetailcomponent{ ngafterviewinit() { console.log('detail.location ', window.location); } } ///////////// //notesdetail html: <a routerlink="/notes" routerlinkactive="active">notes</a> //notes html: <a routerlink="/detail" routerlinkactive="active">detail</a>
when visit routerlink="/detail can see console: detail.location when visit routerlink="/notes" can't see console: notes.location... why? please
maybe reason in parent module:
@ngmodule({ imports: [ browsermodule, homemodule, notesmodule, ngbmodule, routermodule.forroot([ { path : '', loadchildren : './home/home.module#homemodule'}, { path : 'notes', loadchildren : './notes/notes.module#notesmodule'} ]) ], providers : [homeservice, appglobal], declarations : [appcomponent], bootstrap : [appcomponent] })
wiki
Comments
Post a Comment