Angular 服务删除方法

问题描述

我正在尝试使用 angular services 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);

Details

相关问答

Selenium Web驱动程序和Java。元素在(x,y)点处不可单击。其...
Python-如何使用点“。” 访问字典成员?
Java 字符串是不可变的。到底是什么意思?
Java中的“ final”关键字如何工作?(我仍然可以修改对象。...
“loop:”在Java代码中。这是什么,为什么要编译?
java.lang.ClassNotFoundException:sun.jdbc.odbc.JdbcOdbc...