3
を輸入していない私は、テンプレート内のオブジェクトキーを反復処理する必要があるので、私はこのカスタムパイプ製: カスタムパイプが正しく
import {PipeTransform, Pipe} from "@angular/core";
@Pipe({name: "keys"})
export class KeysPipe implements PipeTransform {
transform(value: any, args?: any[]): any[] {
return Object.keys(value);
}
}
をそして、私のページ内でそれは次のようにインポートします:
import {KeysPipe} from "../../pipes/keys-pipe";
import {Component} from '@angular/core';
@Component({
selector: 'page-history',
templateUrl: 'history.html',
pipes: [ KeysPipe ]
})
export class HistoryPage {}
しかし、私がプロジェクトをビルドすると、このエラーが発生します:
引数 '{セレクタ:文字列; templateUrl:文字列;パイプ:タイプKeysPipe []; } 'は' Component '型のパラメータに代入不可能です。オブジェクトリテラルは既知のプロパティのみを指定し、 'pipes'は 'Component'タイプには存在しません。
私はそれをapp.module.ts
でもapp.component.ts
でも宣言しませんでした。おかげさまで
おやおや、素敵な作品です。私はいくつかの古いチュートリアルを読んでいるに違いない...ありがとうalot :) – Senorihl