2.2.模板代码-删除

Service

src/app/plan/plan.service.ts

import {Injectable} from '@angular/core';
import {Observable} from 'rxjs';
import {HttpClient, HttpHeaders} from '@angular/common/http';
import {Plan} from '../../domain/plan';


const httpOptions = {
  headers: new HttpHeaders({'Content-Type': 'application/json'})
};


@Injectable({
  providedIn: 'root'
})
export class PlanService {

  constructor(private http: HttpClient) {
  }

  /**
   * 删除计划
   *
   * @param id 计划的id
   */
  deletePlan(id: string): Observable<any> {
    const url = '/mo/v1/plan/' + id;
    return this.http.delete(url);
  }

}

父组件部分

模板

src/app/plan/plan.component.html

控制器

src/app/plan/plan.component.ts

Last updated

Was this helpful?