2
Observe the code below;
import { Location } from '@angular/common';
@Component({
selector: 'app-node-paginate',
templateUrl: './node-paginate.component.html',
styleUrls: ['./node-paginate.component.css']
})
export class NodePaginateComponent implements OnInit {
constructor(private location: Location) {}
ngOnInit() {
this.load();
}
load() {
location.reload()
}
This code above it performs a refresh on the screen uninterruptedly, but what I really need is for it to do only a refresh.
My goal is when the user access the page, the page can perform a refresh of screen, but it needs to be only a refresh and not several as is happening today.
At the request of Guilherme Costamilam
That’s the problem I’m having too;
I’m using the version 6 angular.
I also tried this way to know what came out on the console.;
import { Component, OnInit, HostListener } from '@angular/core';
import { Location } from '@angular/common';
@Component({
selector: 'app-node-paginate',
templateUrl: './node-paginate.component.html',
styleUrls: ['./node-paginate.component.css']
})
export class NodePaginateComponent implements OnInit {
public innerWidth: any;
constructor(private location: Location) {}
ngOnInit() {
this.innerWidth = window.innerWidth;
console.log(this.innerWidth);
this.load();
}
load() {
console.log(sessionStorage);
//Session storage salva os dados como string
(sessionStorage.refresh == 'true' || !sessionStorage.refresh) && location.reload();
sessionStorage.refresh = false;
}
@HostListener('window:resize', ['$event'])
onResize(event) {
this.innerWidth = window.innerWidth;
}
}
And I got that result;
But I don’t understand why you’re not recognizing the variable refresh
Managed to solve?
– Eduardo Ribeiro