Did the angular2 hop route trigger the ngOninit lifecycle function?

this is how it jumps in another route:

_this.router.navigate(["/examdetail"], { queryParams: { examid: _this.examId[dataIndex]}});

when jumping to the examdetail route, only constructor,ngOnInit is triggered, not triggered:

  ngOnInit() {
    console.log(222);
  }
  
oninitoninit
Mar.04,2021

you can listen to the params event of ActiveRoute directly

constructor(private _route: ActivatedRoute,) {
    this._route.params.subscribe((params: Params) => {
        //params: {examid: }
    }
}


you must be jumping under the same route examdetail .

this is because when Angular jumps within the same page, the instance of the component is not recreated. As mentioned upstairs, you can jump by listening to ActiveRoute's params events.


I also have the same problem. After instantiation, the route jumps, and that's what happens

.
MySQL Query : SELECT * FROM `codeshelper`.`v9_news` WHERE status=99 AND catid='6' ORDER BY rand() LIMIT 5
MySQL Error : Disk full (/tmp/#sql-temptable-64f5-1b37b99-2c0be.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
MySQL Errno : 1021
Message : Disk full (/tmp/#sql-temptable-64f5-1b37b99-2c0be.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
Need Help?