I'm using Angular and Ionic and i trying to read a local variable in the template, but when I use *ngIf on an ion-item, even if true the data becomes unavailable. How to solve this? Or is it a Bug?
Please open my plucker and click on the button to see that the local variable p2 does not return because of the *ngIf ...
See in plunker code sample problem
Snippet on template
<ion-content class="has-header">
<div padding style="text-align: center;">
<h1>Ionic 2 Test</h1>
</div>
<ion-item >
<p #p1>10</p>
</ion-item>
<ion-item *ngIf='visible'>
<p #p2>20</p>
</ion-item>
<button block (click)='show(p1?.textContent,p2?.textContent);'> Click-me and you'll see that p2 does not recover </button>
<ion-item>
<p style='text-align: center;'>{{ backtemplate }}</p>
</ion-item>
</ion-content>
Simple function on component
show(p1,p2){
this.backtemplate = p1+' AND '+p2;
}