我导航到/posts
(localhost:4200/posts
),但是当我刷新页面时ngOnInit()
的页面AppComponent
没有被调用。
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?