错误:使用 ng build --prod 构建时无法解析服务的所有参数

ERROR in : Can't resolve all parameters for Service when build with ng build --prod

数据服务

import { Injectable } from '@angular/core';
import { Http, RequestOptions, Headers } from "@angular/http";
import { environment } from "../../environments/environment";
import 'rxjs/add/operator/map';

@Injectable()
export class DataService {

  public options: RequestOptions;

  constructor(protected url: string, protected http: Http) {
  }

  getAll() {
    return this.http.get(this.url, this.options)
      .map(
      response => response.json()
      )
  }

  get(id: string) {
    return this.http.get(this.url + '/' + id, this.options)
      .map(response => {
        return response;
      })
  }

  create(resource) {
    return this.http.post(this.url, resource, this.options)
      .map(response => {
        return response;
      })
  }

  update(resource) {
    return this.http.put(this.url, resource);
  }

  delete(id: string) {
    return this.http.delete(this.url + '/' + id)
  }


}

儿童服务

import { Injectable } from '@angular/core';
import { DataService } from "../data.service";
import { Http, RequestOptions } from "@angular/http";
import { environment } from "../../../environments/environment";

@Injectable()
export class ChildService extends DataService{

  constructor(http:Http) {
    super(environment.url,http);
  }

}

我正在创建一个具有所有 http 方法(获取、创建、删除、更新)的服务 DataService,并且项目中使用的所有服务都扩展了 DataService.In 我传递的 DataService 的构造函数http对象和子class的url通过对父constuctor.In调用super(url,http)这样我在最新版本中收到错误cli 但不是在较旧的 versions.I 中 getting 使用 ng build --prod[= 构建时出现此错误23=] 和 ng build 中没有得到 错误。任何人都可以帮忙。

我找到问题了!

您将数据服务标记为@Injectable,但构造函数具有不可注入的参数(url:字符串)。

您必须从提供者列表中删除 DataService 并删除 @Injectable 标签