Look at 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 refreshes the screen uninterruptedly, but what I really need is for it to refresh.
My goal is when the user accesses the page, the page can perform a screen refresh, but it needs to be only a refresh and not several as is happening today.
At the request of Guilherme Costamilam
This is a problem I'm having too;
I'musingversion6ofAngular.
Ialsotriedthiswaytoknowwhatcameoutintheconsole.log;
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']})exportclassNodePaginateComponentimplementsOnInit{publicinnerWidth:any;constructor(privatelocation:Location){}ngOnInit(){this.innerWidth=window.innerWidth;console.log(this.innerWidth);this.load();}load(){console.log(sessionStorage);//Sessionstoragesalvaosdadoscomostring(sessionStorage.refresh=='true'||!sessionStorage.refresh)&&location.reload();sessionStorage.refresh=false;}@HostListener('window:resize',['$event'])onResize(event){this.innerWidth=window.innerWidth;}}
AndIhadthisresult;
But I do not understand why you are not recognizing the variable refresh