本文介绍了Angular 9生产错误:无法设置仅具有吸气剂的(抽象)类MyFilter {}的属性ɵfac的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我在一个库中有一个抽象组件(没有常春藤),它带有一个@Directive()
装饰器,该装饰器具有一些继承给其子代的基本属性和功能.当我尝试在任何项目中使用该库时,在浏览器的控制台中出现以下错误:
I have an abstract component in a library (without ivy) with a @Directive()
decorator that has some basic attributes and functions to inherit to its children. When I'm trying to use the library in any project, I'm getting the following error in the browser's console:
Uncaught TypeError: Cannot set property ɵfac of class MyFilter {} which has only a getter
这是课程:
@Directive()
export abstract class MyFilter<T> {
@Input() form: FormGroup;
@Input() filterOpened: boolean;
@Input() enableSubmit: boolean;
abstract useFilter();
}
一个子班:
@Component({
selector: 'my-text-filter',
templateUrl: './text-filter.html',
styleUrls: ['./text-filter.scss']
})
export class MyTextFilter extends MyFilter<TextFilter> implements OnInit, OnChanges {
constructor() {
super();
}
ngOnInit() {
}
ngOnChanges(changes: SimpleChanges) {
}
useFilter() {
}
}
推荐答案
您只需要从MyFilter类中删除@Directive()装饰器即可.
You just need to remove the @Directive() decorator from MyFilter class.
这篇关于Angular 9生产错误:无法设置仅具有吸气剂的(抽象)类MyFilter {}的属性ɵfac的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!