@ArsalanSavand wrote:
Hi,
I’m using Ionic 4 latest beta version and all my pages and components are lazy loaded.
I have a component called “EntriesComponent” that in its ngOnInit function I get data from an endpoint, and everything works fine.Problem is, when I’m already in my EntriesComponent view ( route ) and I want to navigate to it again, the component’s
ngOnInit
function won’t fire also the constructor.import { Component, OnInit } from '@angular/core'; import Entry from '../../models/entry'; import { AuthService } from '../../services/auth/auth.service'; @Component({ selector: 'app-entries', templateUrl: './entries.component.html', styleUrls: ['./entries.component.scss'] }) export class EntriesComponent implements OnInit { entries: Array<Entry> = []; constructor(private authService: AuthService) { } ngOnInit() { this.authService.entries().subscribe((data: Array<Entry>) => { this.entries = data; console.log(data); }); } }
How can I navigate to same route and fire constructor to get my data from the endpoint.
Posts: 3
Participants: 2