angular - 绑定(bind)表达式不能在表达式 ANGULAR 7 的末尾包含链式表达式

标签 angular angular6 angular7

npm run build 时显示的错误

    Parser Error: Binding expression cannot contain chained expression at the end of the expression [getImageUrl(image, true);] in E:/Work/JamesJ/Pixie/pixie-image-editor/source/src/app/image-editor-ui/panels/open-sample-image-panel/open-sample-image-panel.component.html@34:9 ("

<div class="samples" *ngIf="sampleImages" >
    <img [ERROR ->][src]="getImageUrl(image, true);" *ngFor="let image of sampleImages" (click)="openSampleImage(image)"")
: Parser Error: Binding expression cannot contain chained expression at the end of the expression [getImageUrl(image, true);] in E:/Work/JamesJ/Pixie/pixie-image-editor/source/src/app/image-editor-ui/panels/open-sample-image-panel/open-sample-image-panel.component.html@34:9 ("

<div class="samples" *ngIf="sampleImages" >
    <img [src]="getImageUrl(image, true);" [ERROR ->]*ngFor="let image of sampleImages" (click)="openSampleImage(image)">
</div>")
: Parser Error: Binding expression cannot contain chained expression at the end of the expression [getImageUrl(image, true);] in E:/Work/JamesJ/Pixie/pixie-image-editor/source/src/app/image-editor-ui/panels/open-sample-image-panel/open-sample-image-panel.component.html@34:9 ("ngIf="sampleImages" >
    <img [src]="getImageUrl(image, true);" *ngFor="let image of sampleImages" [ERROR ->](click)="openSampleImage(image)">
</div>")

html代码是
    <div class="samples" *ngIf="sampleImages" >
    <img [src]="getImageUrl(image, true);" *ngFor="let image of sampleImages" (click)="openSampleImage(image)">
</div>

组件代码为:
public getImageUrl(image: SampleImage, useThumbnail = false) : string {
    const url = (image.thumbnail && useThumbnail) ? image.thumbnail : image.url;
    // prefix relative link with base url, if needed
    if (url.indexOf('//') === -1) {
        return this.config.getAssetUrl(url);
    } else {
        return url;
    }
}

最佳答案

删除分号:

    <img [src]="getImageUrl(image, true)" ...>

关于angular - 绑定(bind)表达式不能在表达式 ANGULAR 7 的末尾包含链式表达式,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/56240813/

相关文章:

angular7 - 为 Angular 7 中的特定组件生成单独的构建文件

Angular 6+ :ProvidedIn a non root module is causing a circular dependency

angular - 我可以使用 distinctUntilKeyChanged 来删除重复的对象吗?

javascript - RxJS Observable - 在订阅上附加主题消费者

在显示页面之前,出现 Angular 白屏一两秒

javascript - 错误消息 - 在使用 Angular 服务原型(prototype)时不是一个函数

javascript - 以 Angular 2读取excel文件

angular - 从 json 创建动态表单时出错找不到名称为 : 'data' 的控件

javascript - 当我更新 "@angular-devkit/build-angular"时样式加载器停止工作

html - 具有可调多列的 Angular 下拉