Angular 服务 未提供 'model' 的参数
Angular service An argument for 'model' was not provided
我有一个服务,它接受 id 作为参数,我正在请求带有 id 的路由,但我在我的服务上收到了上述错误。有什么想法吗?
#服务
const apiBaseUrl = `${environment.apiUrl}/api/userprofile`;
deactivateUserProfileStatus(id: number) {
return this.httpRequestService.put(`${apiBaseUrl}/inactive/${id}`);
}
#ts
DeactivateUserProfileStatus(id: number) {
this.isInProgress = true;
this._userService
.deactivateUserProfileStatus(id)
.pipe(
finalize(() => {
this.isInProgress = false;
})
)
.subscribe({
next: (res) => {
this._notificationService.showSuccess(
'User status has been updated successfully.'
);
// this.generalForm.disable();
this.getUserGeneralDetails();
// this._router.navigate(['transactions']);
},
error: (err) => {
this._notificationService.showError(
'Something went wrong, Try again later.'
);
this.isInProgress = false;
},
complete: () => {
this.isInProgress = false;
},
});
}
}
您应该为您的 PUT
请求添加正文(或至少为空的正文)。
(method) HttpClient.put(url: string, body: any, options: {
headers?: HttpHeaders | {
[header: string]: string | string[];
};
observe?: "body";
params?: HttpParams | {
[param: string]: string | string[];
};
reportProgress?: boolean;
responseType: "arraybuffer";
withCredentials?: boolean;
}): Observable<...> (+14 overloads)
唯一的 GET
请求没有正文的调用仅由 URL。
我有一个服务,它接受 id 作为参数,我正在请求带有 id 的路由,但我在我的服务上收到了上述错误。有什么想法吗?
#服务
const apiBaseUrl = `${environment.apiUrl}/api/userprofile`;
deactivateUserProfileStatus(id: number) {
return this.httpRequestService.put(`${apiBaseUrl}/inactive/${id}`);
}
#ts
DeactivateUserProfileStatus(id: number) {
this.isInProgress = true;
this._userService
.deactivateUserProfileStatus(id)
.pipe(
finalize(() => {
this.isInProgress = false;
})
)
.subscribe({
next: (res) => {
this._notificationService.showSuccess(
'User status has been updated successfully.'
);
// this.generalForm.disable();
this.getUserGeneralDetails();
// this._router.navigate(['transactions']);
},
error: (err) => {
this._notificationService.showError(
'Something went wrong, Try again later.'
);
this.isInProgress = false;
},
complete: () => {
this.isInProgress = false;
},
});
}
}
您应该为您的 PUT
请求添加正文(或至少为空的正文)。
(method) HttpClient.put(url: string, body: any, options: {
headers?: HttpHeaders | {
[header: string]: string | string[];
};
observe?: "body";
params?: HttpParams | {
[param: string]: string | string[];
};
reportProgress?: boolean;
responseType: "arraybuffer";
withCredentials?: boolean;
}): Observable<...> (+14 overloads)
唯一的 GET
请求没有正文的调用仅由 URL。