'Ionic 6 + Angular ion-button prevent to clear memory after page change
I have a problem with Ionic 6 and ion-button. I use tabs and when I go to nested page and then click on back button page doesn't clear memory and I have memory leaks. I happens if I pass ion-button into ng-content. Such error happens even I just put native html button (just click me). If I pass into ng-content any other element such as ion-icon it works good.
I have the very simple test-component
@Component({
selector: 'app-test-cmp',
templateUrl: '<ng-content></ng-content>',
})
export class TestCmp {}
Here is my nested page
@Component({
selector: 'app-test-page',
templateUrl: `
<ion-header>
<ion-toolbar>
<ion-buttons slot="start">
<ion-back-button></ion-back-button>
</ion-buttons>
<ion-title>Test</ion-title>
</ion-toolbar>
</ion-header>
<ion-content>
<app-test-cmp><ion-card>anything here</ion-card></app-test-cmp>
<ion-content>`,
})
export class TestPage {}
This code works well. Here is my memory snapshot.
But if I put ion-button into ion-card memory doesn't clear.
@Component({
selector: 'app-test-page',
templateUrl: `
<ion-header>
<ion-toolbar>
<ion-buttons slot="start">
<ion-back-button></ion-back-button>
</ion-buttons>
<ion-title>Test</ion-title>
</ion-toolbar>
</ion-header>
<ion-content>
<app-test-cmp><ion-button>Ionic button</ion-button></app-test-cmp>
<ion-content>`,
})
export class TestPage {}
Here is memory snapshot
Please, any help/ideas/etc. WebView fails on iOS after surfing between pages
Update
It's somehow connected to ion-content
This code works correctly but crash animation, etc.
@Component({
selector: 'app-test-page',
templateUrl: `
<ion-header>
<ion-toolbar>
<ion-buttons slot="start">
<ion-back-button></ion-back-button>
</ion-buttons>
<ion-title>Test</ion-title>
</ion-toolbar>
</ion-header>
<app-test-cmp><ion-button>Ionic button</ion-button></app-test-cmp>
<ion-content>
......
<ion-content>`,
})
export class TestPage {}
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|


