Angular-无法解析服务的所有参数(?)

时间:2018-06-27 15:59:21

标签: javascript angular angular5

我的简单Angular应用程序遇到问题,无法调试。每当我尝试将服务注入构造函数时,都会收到一条错误消息,提示“无法解析LoginService的所有参数(?)

app.component.ts

import { Component, Injector } from '@angular/core';
import { LoginService } from './login.service';

@Component({
    selector: 'app-home',
    template: require('./app.component.html')
})
export default class AppComponent {

constructor(private loginService: LoginService) {}

}

login.service.ts

import { Injectable } from '@angular/core';
import { HttpClient } from '@angular/common/http';

@Injectable()
export class LoginService {

constructor(private http: HttpClient) {
}

login() {
    // Do http requests here
}

}

app.module.ts

import { NgModule } from '@angular/core';
import { BrowserModule } from '@angular/platform-browser';

import { HttpClientModule, HttpClient } from '@angular/common/http';

// Components
import AppComponent from './app.component';

//Services
import { LoginService } from './login.service';

@NgModule({
  declarations: [AppComponent],
  imports: [BrowserModule, HttpClientModule],
  providers: [LoginService, HttpClient],
  bootstrap: [AppComponent]
})
export default class AppModule {}

似乎是在HttpClient注入周围出现问题,但我无法弄清楚到底是什么。

任何想法在这里有什么问题吗?

2 个答案:

答案 0 :(得分:1)

原来是缺少的进口商品!

      PROGRAM Integral_E_ultra

      IMPLICIT None
      DOUBLE PRECISION NORM,VAL


      CALL E_ultra(VAL)

      STOP
      END


      SUBROUTINE E_ultra(VAL)

      IMPLICIT NONE
      DOUBLE PRECISION NORM,VAL,PI,VALG1
      DOUBLE PRECISION INTEGRALG1(1),ERRORG1(1),PROBG1(1)
      PARAMETER (PI=3.14159265358979D0)

C  Parameters related to the CUBA numerical integration:

      integer ndim,ncomp,mineval,maxeval,verbose,last
      integer fail,nregions,neval
      double precision epsrel,epsabs,userdata
      parameter (ndim=1)
      parameter (userdata=0)
      parameter (ncomp=1)
      parameter (epsrel=1D-3)
      parameter (epsabs=1D-12)

      parameter (verbose=0)
      parameter (last = 4)
      parameter (mineval=0)
      parameter (maxeval=50000)

      integer key1, key2, key3
      parameter (key1 = 47)
      parameter (key2 = 1)
      parameter (key3 = 1)

      integer nstart,nincrease
      parameter (nstart = 1000)
      parameter (nincrease = 500)

      integer nnew
      double precision flatness
      parameter (nnew = 1000)
      parameter (flatness = 25D0)

      integer key
      parameter (key =0)

      EXTERNAL INTG1


      CALL CUHRE(ndim,ncomp,INTG1,userdata,
     +     epsrel,epsabs,verbose+last,mineval,maxeval,
     +     KEY,NREGIONS,neval,fail,INTEGRALG1,ERRORG1,PROBG1)
      VALG1=INTEGRALG1(1)
      VAL=3D0*VALG1/(16*PI**3D0)

      RETURN
      END


      SUBROUTINE INTG1(NDIM,X,NCOMP,RESULT)

      IMPLICIT NONE
      DOUBLE PRECISION X(NDIM),RESULT(NCOMP)
      DOUBLE PRECISION VAR(1),RANGE,JACOBIAN,PI
      DOUBLE PRECISION UPPER(1)
      COMMON/UBOUND/ UPPER
      DOUBLE PRECISION LOWER(1)
      COMMON/UBOUND/ LOWER
      INTEGER NDIM,NCOMP,I
      PARAMETER (PI=3.14159265358979D0)
      Result = 0
      VAR = 0
      RANGE=0D0
      JACOBIAN=1D0      
      LOWER(1)=0D0
      UPPER(1)=1D0    

      DO I=1,NDIM
         RANGE=UPPER(I)-LOWER(I)
         JACOBIAN=JACOBIAN*RANGE
         VAR(I)=LOWER(I)+X(I)*RANGE
      ENDDO

      CALL INTEGRANDG1(RESULT,VAR)
      RESULT(1)=RESULT(1)*JACOBIAN

      RETURN
      END


      SUBROUTINE INTEGRANDG1(RESULT,VAR)

      IMPLICIT NONE
      DOUBLE PRECISION VAR(1),RESULT(*)
      DOUBLE PRECISION NORM,LAMBDA,ALPHA,K,M,G1
      LAMBDA = 1
      K=1
      G1 = 0
      ALPHA = VAR(1)
      G1= -(LAMBDA**2*K*M*ALPHA)/(K**2+LAMBDA**2)**2
      RESULT(1) = G1

      RETURN
      END

答案 1 :(得分:0)

如果您已经升级到Angular 9+,但是禁用了Ivy,并且您使用的是在打开Ivy的情况下使用ngc编译的库,则也会发生这种情况。解决方案是升级到Ivy或要求库所有者也生成非Ivy版本。