[AppComponent的ngOninit钩子没有在页面刷新上被调用

问题描述 投票:1回答:1

我导航到/postslocalhost:4200/posts),但是当我刷新页面时ngOnInit()的页面AppComponent没有被调用。

angular typescript
1个回答
-1
投票
import { Component, OnInit } from '@angular/core';

export class App implements OnInit {
  constructor() {
     // Called first time before the ngOnInit()
  }

  ngOnInit() {
     // Called after the constructor and called  after the first ngOnChanges() 
  }
}
is this the same way you have implemented in your project?
© www.soinside.com 2019 - 2024. All rights reserved.