割り当て可能ではありません、私は次のビルドエラーを取得しています:活字のエラー:文字列は、フィルタのコードを書きながら、私はAngular2でカスタムパイプを作成してい
TS2322: Build:Type'() => string' is not assignable to type 'string'
以下の私のサンプルコードを見つけてください:
私はtypescripに新しいですlet filter:
:
import { PipeTransform, Pipe } from 'angular2/core';
import { IProduct } from './products';
@Pipe({
name: 'productFilter'
})
export class ProductFilterPipe implements PipeTransform {
transform(value: IProduct[], args: string[]): IProduct[] {
let filter: string = args[0].toLocaleLowerCase ? args[0].toLocaleLowerCase : null;
return filter ? value.filter((product: IProduct) =>
product.productName.toLocaleLowerCase().indexOf(filter) != -1) : value;
}
}
上記のエラーは、コードの行を次のようにしてい誰かがこの問題を解決するために私を助けることができますか?
'let filter = args [0] .toLocaleLowerCase?.......... 'のみを使用しようとしています – micronyks