Angular 服务删除方法
Angular Service Delete method
我正在尝试使用 angular 服务 delete
方法删除客户,但我不知道如何从 angular 组件动态传递 id
参数.谁能告诉我如何动态传递 id
?
deleteCustomerById(id: number): Observable<number>
{
const httpOptions =
{
headers: new HttpHeaders({ 'Content-Type': 'application/json'})
};
return this.http.delete<number>('http://localhost:58274/api/Customers/{id}' + id, httpOptions);
}
您正在寻找:
this.http.delete<number>(`http://localhost:58274/api/Customers/${id}`, httpOptions);
我正在尝试使用 angular 服务 delete
方法删除客户,但我不知道如何从 angular 组件动态传递 id
参数.谁能告诉我如何动态传递 id
?
deleteCustomerById(id: number): Observable<number>
{
const httpOptions =
{
headers: new HttpHeaders({ 'Content-Type': 'application/json'})
};
return this.http.delete<number>('http://localhost:58274/api/Customers/{id}' + id, httpOptions);
}
您正在寻找:
this.http.delete<number>(`http://localhost:58274/api/Customers/${id}`, httpOptions);