我的应用程序在使用 JIT 编译器时似乎可以工作,但是当我尝试使用 AOT 编译器时ng build --prod
然后它抛出一个错误:
ERROR in : Can't bind to 'disabled' since it isn't a known property of 'div'. ("[ERROR ->]<div formButton></div>")
我如何找出这个错误来自哪里?
我只是添加了延迟加载的功能模块,而不是导入中的所有内容app.module.ts
我不知道是否需要导入FormButtonComponent
进入功能模块?
我搜索了代码库,但找不到任何实例formButton
是在任何东西上,除了button
.
Here's button.component.ts
:
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
<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>