0

Using AngularJS i can do it:

item in (filteredList.sup = (nozzles | rangeFilter: { flow: calc.q.tempFlow, pressure: calc.pressure } | orderBy: 'pressao'))

I've made a ng-repeat and the result of them, i have set into filteredList.sup variable.

I'm trying to do the same using Angular 2, but isn't so easy as AngularJS (I'm new on Angular 2)

.

I tried: ng2: How to create variable in ngFor loop

and

https://github.com/angular/angular/issues/2451

Without success! :/

PS* If i can use my pipes inside the "controller"/component.ts it can help too.

Actual code:

listService.ended
    | filterBy: { empresaId: selectedCompany }
    | filterOperador: filtroOperador
    | dateRange: dateRange.min : dateRange.max

filterBy = https://www.npmjs.com/package/ng2-filter-pipe

filterOperador & dateRange = Custom Pipes

Community
  • 1
  • 1

1 Answers1

2

In Angular2, it can't be implemented, but as mentioned here in Angular4, you can implement this again just like we did in angularjs.

*ngFor="let user of userObservable | async as results;

If i can use my pipes inside the "controller"/component.ts it can help too.

yes, if you don't mind using Pipe twice in template and component, you can call your pipes at component this way:

// inject the Pipe
constructor(pipe: XXXPipe){}

getPipeResult() {
  // call Pipe's transform
  let pipeResult = this.pipe.transform(input, arg1, arg2, ...)
}
Pengyy
  • 37,383
  • 15
  • 83
  • 73