我想让这段代码立即运行,而不是在ngOnInit方法中运行。因此,如果我转到该页面,该代码应立即运行:
ngOnInit() {
this.service
.getEmployees()
.subscribe(
(listBooks) => {
this.books = listBooks;
this.events = this.books.map((book) => {
return {
start: new Date(book.date_from_og),
end: new Date(book.date_to_og),
type: ""+book.type,
title: "" + book.device + "",
color: colors.blue,
actions: this.actions,
resizable: {
beforeStart: false,
afterEnd: false
},
draggable: false
}
});
},
(err) => console.log(err)
);
}
谢谢您的回答!
编辑: 数组“事件”在日历中显示事件,但是我总是必须单击一下才能出现。我实际上希望它们立即出现