2
내가 내 Angular2 구성 요소에 dhtmlx onEmptyClick
이벤트를 사용할 angular2 구성 요소, 내부 dhtmlx하지만 오류가 점점 :내 구성 요소의 기능은 <code>changewall()</code>라고 전화 할 내부
this.changeWall is not a function
을 나는 외부 scheduler.attachEvent
을 changewall()
을 넣으면 신체가 잘 작동합니다. 왜 이런 일이 일어나는 걸까요?
작동하지 않습니다 :
scheduler.attachEvent("onEmptyClick", function (date, e){
console.log('clickBefore');
this.changeWall(1511305200000);
console.log('clickAfter');
});
본 작품 :
this.changeWall(1511305200000);
scheduler.attachEvent("onEmptyClick", function (date, e){
console.log('clickBefore');
console.log('clickAfter');
});
전체 코드 :
import {Component, OnInit, AfterViewInit, HostListener} from '@angular/core';
import {WallService} from "../../services/wall.service";
declare var scheduler:any; //hide errors
@Component({
moduleId: module.id,
selector: 'big-calendar',
templateUrl: 'calendar2.component.html',
styleUrls: ['calendar2.component.scss']
})
export class Calendar2Component implements AfterViewInit {
private wallInstance: any;
events: any;
constructor(private _wall: WallService) {
}
@HostListener('click', ['$event'])
onClick(e) {
// this.refreshCalendar();
}
refreshCalendar(){
let date = new Date(scheduler.getState().date);
let month = date.getMonth() + 1;
let year = date.getFullYear();
// scheduler.clearAll();
scheduler.attachEvent("onEmptyClick", function (date, e){
console.log('clickBefore');
this.changeWall(1511305200000);
console.log('clickAfter');
});
this._wall.getCalendarEvents(month, year).subscribe((data: any)=>{
console.log(data);
let i = 0, events = [];
while(i < data.events.length){
events.push({
holder: "t", //userdata
room: "1" ,
text: data.events[i].name,
start_date: data.events[i].start,
end_date: data.events[i].end +1
});
i++;
}
console.log(events);
scheduler.init('scheduler_here',new Date(),"month");
scheduler.parse(events,"json");
});
}
ngAfterViewInit(): void {
scheduler.config.touch = "force";
this.refreshCalendar();
// scheduler.parse([
// {id:1, text:"Meeting", start_date:"04/11/2016 14:00",end_date:"14/12/2016 17:00"}
// ],"json");
}
changeWall(timestamp){
// let timestamp = new Date(date).getTime();
// console.log(timestamp);
this.wallInstance = this._wall.getInstance();
this.wallInstance.timeChanger(timestamp);
}
}
OMG를 참조
하고 또한
function
를 사용하는 다른 장소를 변경해야합니다! THANK U SO MUCH – uppermost
이 질문에 대한 답변을 얻으려면 질문에 답하도록 명확히하기 위해 up/downvote 단추 아래의 확인 표시를 클릭하여 수락하는 것이 좋습니다. 감사. –