2017-09-12 4 views
0

私はdevextremeスケジューラを使用して予定スケジューラのアプリを作ろうとしています。 私は少しバグがあります。私は私が約束してドラッグを作成するときに、理由を知りたいと、私はちょうど作成予定をドロップし、私は私のコンソール上でこのエラーを持っているでしょう:devextremeスケジューラのプラグインのリフレッシュエラー - 角4

PUT http://localhost/v0/croissant/undefined 404 (Not Found) 
appointment.service.ts:19 An error occurred Response {_body: "", status: 404, ok: false, statusText: "Not Found", headers: Headers…} 
webpackJsonp.../../../../../src/app/services/appointment.service.ts.AppointmentService.handleError @ appointment.service.ts:19 
ZoneDelegate.invoke @ zone.js:203 
onInvoke @ core.es5.js:3890 
ZoneDelegate.invoke @ zone.js:202 
Zone.run @ zone.js:96 
(anonymous) @ zone.js:462 
ZoneDelegate.invokeTask @ zone.js:236 
onInvokeTask @ core.es5.js:3881 
ZoneDelegate.invokeTask @ zone.js:235 
Zone.runTask @ zone.js:136 
drainMicroTaskQueue @ zone.js:368 
ZoneTask.invoke @ zone.js:308 
core.es5.js:1020 ERROR Error: Uncaught (in promise): Response with status: 404 Not Found for URL: http://localhost/v0/croissant/undefined 

しかし、私はページを更新し、その後、私は予定を移動すると、すべてのもの正常に動作します...ここここ

は私の更新予定の方法は、私のappointment.Service.tsである

updateAppointment(id: string, userId :string, timestamp :string, reason: string): Promise<Appointment>{ 

    let bodySearchParam = new URLSearchParams(); 
    bodySearchParam.append('userId', userId); 
    bodySearchParam.append('timestamp', this.datetotimestamp(timestamp).toString()); 
    bodySearchParam.append('reason', reason); 
    let body = bodySearchParam.toString(); 


    var AppointmentUrlUpdate = this.AppointmentUrlWrite + "/" + id; 

    return this.http.put(AppointmentUrlUpdate, body) 
        .toPromise() 
        .then(response => 
         console.log("event updated") 
        ) 
        .catch(this.handleError); 

    } 

は私のカレンダーコンポーネント

の私なeventHandlerです私は

<dx-scheduler 
    (onAppointmentUpdated)= "updateAppointment($event)" 
> 

</dx-scheduler> 

私calendar.component.htmlに私なeventHandlerを呼び出すのはここ

とは、あなたの助けのための感謝!

答えて

0

問題は、私のAPIの必要性とIDは、予定を更新することです。しかし、IDは現在格納されていません。解像度の方法は次のとおりです。

createAppointment(userId :string, timestamp :string, reason: string): Promise<Appointment> { 

    let bodySearchParam = new URLSearchParams(); 
    bodySearchParam.append('userId', userId); 
    bodySearchParam.append('timestamp', this.datetotimestamp(timestamp).toString()); 
    bodySearchParam.append('reason', reason); 
    let body = bodySearchParam.toString(); 

    console.log(body) 
    return this.http.post(this.AppointmentUrlWrite,body) 
        .toPromise() 
        .then(response => 
        this.createdId = response.json().id // Get the appointment's ID 
       ) 
        .catch(this.handleError); 
    } 

はcreatedIDを返す関数ます状態はすでにの任命に役立つ

if(e.appointmentData.id == null){e.appointmentData.id = this.appointmentService.getCreatedId();} 

getCreatedId(){ 
    return this.createdId; 
    } 

とupdateAppointment方法でこれを行いますidを持つ(すべての予定はページを更新した後にIDを持つ)

それは別のもののために役立つことを願って:)

関連する問題