У меня есть простая труба, которая фильтрует массив студентов. Здесь код (Plnkr)
import {Pipe} from 'angular2/core';
@Pipe({
  name: 'sortByName',
  pure: false
})
export class SortByNamePipe {
  temp = [];
  // i = 0;
  transform (value, [queryString]) {
    // console.log(this.i++);
    // console.log(value, queryString);
    // This does not work
    this.temp = value.filter((student)=>(student)=>student.name.includes(queryString)))
    return value.map(function(val){ return val.name.toUpperCase()});
    // This works
    // this.temp.length = 0;
    // this.temp.push(...value.filter((student)=>student.name.includes(queryString)))        
    // return this.temp;
  }
}
Как вы можете видеть в Plnkr, Angular выдает ошибку с использованием первого метода.
EXCEPTION: Expression 'students | sortByName:queryElem.value  in [email protected]:6' has changed after it was checked. Previous value: 'SON,DAVID'. Current value: 'SON,DAVID' in [students | sortByName:queryElem.value  in [email protected]:6]
Почему?
