在查看文档时,我注意到调度程序组件没有从 fullcalendar 控件中公开 slotLabelFormat。设置此属性的推荐解决方法是什么?
谢谢,
路易斯
在查看文档时,我注意到调度程序组件没有从 fullcalendar 控件中公开 slotLabelFormat。设置此属性的推荐解决方法是什么?
谢谢,
路易斯
我之前需要为另一个组件做类似的事情。事实证明,仅仅因为该属性不是@Input()
,甚至没有明确设置为 public,并不意味着您无法访问它。
我做了类似的方式:
@Component({
selector: 'blah',
template: `<custom-component #foo ></<custom-component>`
})
export class MyComponent {
// You can leave it as `any` or use the actual component type if available
@ViewChild("foo") myCustomComponent;
ngAfterViewInit() {
this.myCustomComponent.prop = 'value';
// Above should work with `any`.
// If you are using component type, and it fails, try `any` or try:
this.myCustomComponent["prop"] = 'value';
}
}
它并非一直有效,并且ngAfterViewInit
设置属性可能为时已晚。
另一种选择是继承组件。那就是创造
class CustomComponentChild extends CustomComponent
. 为此,您至少需要 Angular 2.3,并且您必须使用实际组件并复制整个@Component()
装饰器,因为装饰器不会复制或合并到 Angular 中的子组件。
经过一番挖掘(即查看此处找到的源代码,事实证明,Schedule 控件公开了一个名为 schedule 的属性,它允许您访问 jquery fullcalendar 插件。有了这些信息,现在只需使用 API:
ngAfterViewInit(){
//this._agenda is of type Schedule
this._agenda.schedule.fullCalendar("option", "slotLabelFormat", "HH:mm");
}