小编Han*_*och的帖子

将参数传递给服务构造函数?

我正在尝试在组件中实例化服务。我收到这个错误

未捕获的错误:无法解析 AuthenticationService 的所有参数:(?, [object Object], ?)。

这是我的服务

     @Injectable()
    export class AuthenticationService {

      protected basePath = 'http://localhost:8080/rest';
      public defaultHeaders: Headers = new Headers();
      public configuration: Configuration = new Configuration();

      constructor(protected http: Http, @Optional() @Inject(BASE_PATH) basePath: string, @Optional() configuration: Configuration) {
        if (basePath) {
          this.basePath = basePath;
        }
        if (configuration) {
          this.configuration = configuration;
          this.basePath = basePath || configuration.basePath || this.basePath;
        }
      }

    public login(authenticationkey?: string, body?: AuthenticationRequestHolder, extraHttpRequestParams?: any): Observable<AuthenticationBundle> {
        return this.loginWithHttpInfo(authenticationkey, body, extraHttpRequestParams)
          .map((response: Response) => {
            if …
Run Code Online (Sandbox Code Playgroud)

typescript angular-services angular

3
推荐指数
1
解决办法
7741
查看次数

C编译或/和解释?

关于"编译与解释"有很多答案和引文,我确实理解它们之间的差异.

说到C,我不确定.C是编译还是解释或两者兼而有之?如果你加上一些解释,我真的很感激.

c c++

-1
推荐指数
3
解决办法
1万
查看次数

标签 统计

angular ×1

angular-services ×1

c ×1

c++ ×1

typescript ×1