我具有以下手风琴组件:
export class AccordionComponent {
@ContentChildren(PanelComponent) panels: QueryList<PanelComponent>;
open(panel: PanelComponent) {
this.panels.toArray().forEach(panel => panel.active = false);
panel.active = true;
}
close(panel: PanelComponent) {
panel.active = false;
}
}
其中PanelComponent是:
export class PanelComponent {
@Input() active: boolean;
@Input() title: string;
accordion: AccordionComponent;
constructor(@Inject(forwardRef(() => AccordionComponent)) accordion: AccordionComponent) {
this.accordion = accordion;
}
toggle() {
if (this.active)
this.accordion.close(this);
else
this.accordion.open(this);
}
}
我正在将AccordionComponent注入PanelComponent,因此当打开一个面板时,我可以关闭所有其他面板...
我编译时收到警告:
WARNING in Circular dependency detected:
accordion.component.ts -> panel.component.ts -> accordion.component.ts
我不理解警告,但是如何避免呢?
在许多使用forwardRef的情况下会不会发生这种情况?
答案 0 :(得分:0)
我建议改用from scipy.interpolate import interp1d
y = np.arange(e[0],e[-1],0.001)
l = [0 if i==0 else 1 for i in interp1d(e,x)(y)]
xDat = splev(y,splrep(e,x)) * l
plt.plot(x,e,'k.',xDat[xDat>=0],y[xDat>=0],'r-',lw=0.5)
,因为这是它们的用例类型。像这样:
Output
然后只听export class PanelComponent {
@Input() active: boolean;
@Input() title: string;
@Input() close = new EventEmitter();
@Input() open = new EventEmitter();
constructor() {}
toggle() {
if (this.active)
this.close.emit(this);
else
this.open.emit(this);
}
}
上的事件:
PanelComponent