我的应用程序在使用即时编译器时似乎可以工作,但当我尝试使用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
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>
发布于 2018-05-17 11:13:07
意思是在代码中的某个地方让<div formButton></div>
搜索代码并将其删除
https://stackoverflow.com/questions/50382710
复制相似问题