Refresh page when the screen orientation is changed


Hello guys, I am using ag-grid to display som data, and when the screen orientation is changed I need the grid to be resized.
Right now to resize it, I am reloading the page in this way(Btw it’s in the constructor): this.screenOrientation.onChange().subscribe( () => { this.navCtrl.setRoot(this.navCtrl.getActive().component); } )

This works, but is far from good…
The first time the orientation is changed it won’t resize. Then it goes in some kind of loop. Second time orientation is changed setRoot is called 2 times, then 4 times, then 8 etc. This makes the list for the grid slower and slower to load.

Anyone that have an idea what I am doing wrong/what I should do?


Put it in ionViewDidEnter and unsubscribe in ionViewWillLeave?

U r suffering from stacking subscriptions for sure


Thanks, this solved the problem with the increasing loop.

However, now I got a new problem.
It is resizing to the previous “screen” size, and not the current.
I think it’s because the HTML that defines the size of the grid runs before ionViewDidEnter() is called.
Do you have any idea to solve this?