You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I have two pages, each one has an ngFor with a simple pipe over a collection of (differently) typed items
I have an @Injectable () class with some protected fields and methods. The two pages inherit this class
The problem:
when I go from the first page to the second, I get an error on the console saying that there's no differ for the type of the first page
The debug:
I tried debugging and I see that before going to the second page, the pipe gets called
it seems that the return of the pipe is getting evaluated on the second page, and that's why it breaks (removing the pipe in the second template doesn't solve the issue)
If I remove the inheritance from the second page, of course, everything works just fine.
What behavior are you expecting?
Either the pipe transform doesn't get hit, or it doesn't throw an exception.
Steps to reproduce:
Is there a plnkr where I could try to reproduce this?
// master page
@Injectable ()
export class MasterPage {
protected ToRevert : number[] = [];
onPageDidEnter () {
this.ToRevert = [];
}
}
//a snippet from the template. As you can see the call to the second page is inside an item of a list, is this why the pipe gets called?
<ion-item *ngFor="#item of Dn | userFilter:inputFilter.value:onlySel:'descrizione'; #i = index"
[ngClass]="{green: item.selected}">
<ion-row>
<ion-col (click)="toggle(item, i)">
<span>{{item.descrizione}}</span>
<p>Editori: {{item.countEditori}}</p>
</ion-col>
<ion-col>
<a href="#" (click)="gotoEditori(item)"><ion-icon style="float:right;" name="ios-arrow-forward"></ion-icon></a>
</ion-col>
</ion-row>
</ion-item>
</ion-list>
//the pipe
@Pipe({
name: 'userFilter'
})
export class UserFilterPipe implements PipeTransform {
transform(value:any, args:string[]): any {
let filter = args[0].toLocaleLowerCase();
let field = args[2];
let current = (filter && value) ? value.filter(ff => ff[field].toLocaleLowerCase().indexOf(filter) != -1) : value;
if(args[1]){
return current.filter(ff => ff.selected);
}
return current;
}
}
Turns out that removing @Injectable () from the parent class resolves the issue without breaking inheritance, it was stupid of me to use that annotation in the first place. Sorry. Closing this.
Short description of the problem:
The set up:
The problem:
The debug:
If I remove the inheritance from the second page, of course, everything works just fine.
What behavior are you expecting?
Either the pipe transform doesn't get hit, or it doesn't throw an exception.
Steps to reproduce:
Is there a plnkr where I could try to reproduce this?
Ionic Version: 2.x
Browser & Operating System: iOS / Android / Chrome
Run
ionic info
from terminal/cmd prompt:The text was updated successfully, but these errors were encountered: