Angular6 is executed after the page is loaded, not ngOnInit

my front end uses Angular6, to call a method of Angular
after the page is loaded and tested in ngOnInit (), which seems to be executed before the page is loaded.
so what should I do if I want to execute a method of Angular6 after the page is all loaded?
has read the official documents and only has the following hooks on the life cycle:
constructor ()
ngOnChanges ()
ngOnInt ()
ngDoCheck ()
ngAfterContentInit ()
ngAfterContentChecked ()
ngAfterViewInit ()
ngAfterViewChecked ()
ngOnDestory ()
ngAfterContentInit () and ngAfterViewInit ()
have been tested, and neither of them is
thanks any help!

Jul.06,2021

it is estimated that the component you want to execute is not included in the first page of your application settings!


ngAfterViewInit()

ngAfterViewInit is executed after all pages have been rendered. You can try

.

I also have the same problem. Both ngAfterViewInit and ngAfterContentInit have tried this method, but it really doesn't work. It starts when the page is not loaded and cannot even get the passed parameters.


ngOnInit () {

setTimeout(()=>{
    // 
},0)

}

Menu