首页
学习
活动
专区
工具
TVP
发布
社区首页 >问答首页 >Angular 6 production build“无法绑定到'disabled‘,因为它不是’div‘的已知属性”

Angular 6 production build“无法绑定到'disabled‘,因为它不是’div‘的已知属性”
EN

Stack Overflow用户
提问于 2018-05-17 10:59:06
回答 1查看 5.4K关注 0票数 3

我的应用程序在使用即时编译器时似乎可以工作,但当我尝试使用ng build --prod使用AOT编译器时,它会抛出一个错误:

ERROR in : Can't bind to 'disabled' since it isn't a known property of 'div'. ("[ERROR ->]<div formButton></div>")

我如何找出这个错误的来源?

我只是添加了延迟加载的功能模块,而不是导入app.module.ts中的所有内容,我不知道是否需要将FormButtonComponent导入到功能模块中?

我搜索了整个代码库,除了button之外,我找不到任何formButton在任何地方的实例。

这是button.component.ts

代码语言:javascript
复制
import { Component, HostBinding, Input, OnChanges, SimpleChanges } from "@angular/core";

/**
 * Button with loading and disabled states
 */
@Component({
    moduleId: module.id,
    selector: '[formButton]',
    templateUrl: 'button.component.html'
})
export class FormButtonComponent implements OnChanges {
    @Input() loading? = false;
    @Input() disabled? = false;
    @HostBinding('disabled') disabledAttribute = false;

    ngOnChanges(changes: SimpleChanges): void {
        this.updateState();
    }

    updateState(): void {
        this.disabledAttribute = this.disabled || this.loading;
    }
}

button.component.html

代码语言:javascript
复制
<ng-content></ng-content>
<spinner [size]="small" *ngIf="loading"></spinner>

以下是我的应用程序中其他地方的一些示例调用:

<button formButton [loading]="template.loading" [disabled]="disabled" class="button" type="submit">Design</button>

<button formButton class="button" [loading]="form.disabled" (click)="save()">Change Password</button>

<button formButton [ngClass]="buttonClass" (click)="upload()" [loading]="uploaderWrapper.isUploading">{{ buttonText }}</button>

EN

回答 1

Stack Overflow用户

发布于 2018-05-17 11:13:07

意思是在代码中的某个地方让<div formButton></div>搜索代码并将其删除

票数 1
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/50382710

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档