In my application I have a table which is filled by an array and where I use a filter on it. In a OnInit, a promise is called to get the data. Now the problem is that after a refresh, the value of _projects (and the input parameter of transform) is undefined and nothing is shown in the table. When I click a dropdown the transform function is triggered and the table is filled. Is there a way to trigger the pipe when _projects is defined in the promise? I also tried with pure/impure pipes.
this._projectService.getProjectsPromise().done(
function (jsdo, success, request){
that._projects = request.response[HorizonData.dsProjects][HorizonData.dsProjects][HorizonData.ttProjects];
for (let project of that._projects) {
project.WhenWhoCreatedFull = project.WhenWhoCreated
var whenwho = project.WhenWhoCreated.split(" ");
project.WhenWhoCreated = whenwho[0] + " " + whenwho[2];
}
}
)
In my component.html
<tr title="{{ project.INFO }}" *ngFor="let project of _projects | projectFilter: filtered">
Angular Pipe:
transform(value: IProject[], filterBy: IProject): IProject[] {
return filterBy && value ? value.filter((project: IProject) =>
(project.projectnr.toLowerCase().indexOf(filterBy.projectnr.toLowerCase()) !== -1)
&& (project.projectname.toLowerCase().indexOf(filterBy.projectname.toLowerCase()) !== -1)
&& (project.clientnr.toLowerCase().indexOf(filterBy.clientnr.toLowerCase()) !== -1)
&& (project.clientname.toLowerCase().indexOf(filterBy.clientname.toLowerCase()) !== -1)
&& (filterBy.statusdesc.indexOf(project.statusdesc) !== -1)) : value;
}