我正在使用ng-fullcalendar并且出于某种原因,我的代码仅在init上扫描extension NSImage {
func resizedTo(width: CGFloat, height: CGFloat) -> NSImage {
let ratio = min(canvas.width/size.width, canvas.height/size.height)
let canvasSize = NSSize(width: size.width * ratio, height: size.height * ratio)
let img = NSImage(size: canvasSize)
img.lockFocus()
NSGraphicsContext.current?.imageInterpolation = .high
draw(in: NSRect(origin: CGPoint(x: (canvasSize.width - (size.width * ratio)) / 2, y: (canvasSize.height - (size.height * ratio)) / 2), size: canvasSize), from: NSRect(origin: .zero, size: size), operation: .copy, fraction: 1)
img.unlockFocus()
return img
}
}
的值(因此我只得到初始值,而不是值的任何更新),即使检查使用[options]
似乎工作正常。这可能是什么原因?
// component.ts
{{ calendarOptions.events | json }}
// component.html
@Component({
// [...]
changeDetection: ChangeDetectionStrategy.OnPush
})
ngOnInit() {
this.fooCollection = this.afs
.collection('collectionFoo')
.doc('doc')
.collection('collectionBar')
.snapshotChanges()
.map(activities => {
return activities.map(a => {
const data = a.payload.doc.data();
const id = a.payload.doc.id;
return { id, ...data };
});
});
this.fooCollection.subscribe(response => {
this.calendarOptions = {
editable: true,
aspectRatio: 1.618,
eventLimit: true,
header: {
left: 'prev,next today',
center: 'title',
right: 'month,agendaWeek,agendaDay,listMonth'
},
timeFormat: 'HH:mm',
locale: 'it',
timezone: 'local',
events: response
};
this.cd.markForCheck();
});
}