我可以将管道添加到绑定@input decoprador属性吗?

时间:2020-10-15 12:19:26

标签: angular

我有一个具有@Input属性的组件:

@Component({
  selector: 'app-product-details',
  templateUrl: './product-details.component.html'
})
export class ProductDetailsComponent implements OnInit {
  @Input() product: Product;
}

我想像这样绑定此属性:

<app-products-by-category [products]="products | filterByCategory('pizza')"></app-products-by-category>

会导致以下错误:

ERROR in Template parse errors:
Parser Error: Unexpected token '(' at column 28 in [products | filterByCategory('pizza')] in D:/private projects/ecommerces/fuzionm-store/frontend/src/app/modules/product/components/products/products.component.html@3:42 (" class="container" *ngIf="products$ | async as products">
    <app-products-by-category [products]="[ERROR ->]products | filterByCategory('pizza')" [category]=categories.PIZZA></app-products-by-category>
    <!-"): D:/private projects/ecommerces/fuzionm-store/frontend/src/app/modules/product/components/products/products.component.html@3:42
Parser Error: Unexpected token '(' at column 28 in [products | filterByCategory('pizza')] in product/components/products/products.component.html@3:42 ("oducts">
    <app-products-by-category [products]="products | filterByCategory('pizza')" [category]=[ERROR ->]categories.PIZZA></app-products-by-category>
    <!-- <app-products-by-category [products]="filterByC"): product/components/products/products.component.html@3:91

在这种情况下是否可以添加管道?

0 个答案:

没有答案