我创建了一个自定义组件并将其应用于
<input [ERR]="' '" required ngModel name="leaseagreement" type="file" (change)="onFileChange()">
创建[ERR]以显示错误,但该组件的挂钩事件ngOnChanges未在选择文件时执行。 如果以任何方式触发它,请分享。
@Component ({
selector:'[ERR]',
template:`<template #validationref>
<span class="ERR2">{{error}}</span>
</template>
<ng-content></ng-content>
`
})
export class ERR implements OnInit {
@Input() ERR:string;
@Input() ngModel:string;
@ViewChild('validationref') validationref;
public error:string = "";
ngOnInit() {
}
ngOnChanges(args: any[]) {
// my error plugin code
}
}