首页 > 解决方案 > 使用管道时出现属性绑定错误

问题描述

我正在关注本教程

https://ultimatecourses.com/blog/angular-pipes-custom-pipes

我正在尝试使下面发布的代码正常工作。当我调用命令时

ng servr --open

我收到以下错误:

Error occurs in the template of component Appcomponent
ptoperty file does not exist on type Appcomponent

请让我知道为什么我会收到此错误以及如何解决它

app.component.ts

import { Component } from '@angular/core'
@Component({
    selector: 'app-root',
    templateUrl: './app.component.html'
})
export class AppComponent {
    file = { name: 'logo.svg', size: 2120109, type: 'image/svg' };
}

app.component.html

{{文件名}}

{{文件大小 | 文件大小}}

标签: javascriptnode.jsangularjsangular

解决方案


你在 import import { Component } from '@angulat/core' 中有拼写错误

改成

从“@angular/core”导入{组件}


推荐阅读