Ich versuche, einen Dienst in einer Komponente zu instanziieren. Ich habe diesen FehlerParameter an einen Dienstkonstruktor übergeben?
Uncaught Error: Can't resolve all parameters for AuthenticationService: (?, [object Object], ?).
Das ist mein Service
@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 (response.status === 204) {
return undefined;
} else {
return FlexiCoreDecycl`enter code here`e.retrocycle(response.json()) || {};
}
});
}
// More Code
und dies ist die Komponente, die den Dienst
@Component({
selector: 'app-login',
templateUrl: './login.component.html',
styleUrls: ['./login.component.css']
})
export class LoginComponent implements OnInit {
constructor(private _authenticationService: AuthenticationService) {
}
ngOnInit() {
this._authenticationService
.login('', {mail: '[email protected]', password: 'admin'})
.subscribe(response => {
console.log(response);
},
error => {
console.log(error);
});
}
}
verwendet und hier ist das Winkelmodul
@NgModule({
declarations: [
AppComponent,
LoginComponent
],
imports: [
BrowserModule
],
providers: [AuthenticationService],
bootstrap: [AppComponent]
})
export class AppModule { }
Kann mir jemand helfen wie richtig verdrahten? Ich bin neu sowohl für eckige als auch für Schreibmaschinen, also werde ich ein wenig Erklärung und Hinweise schätzen.
ich Ihren Vorschlag und tat es, um nur einige der Forschung, aber das Problem ist immer noch hinzugefügt glaube, dass ich das Problem geschieht, wenn ich versuche, den Dienst der registrieren Anbieter. Ich habe versucht, sie neu zu ordnen, aber nichts hat sich geändert. – Hanoch
@Hanoch Könnten Sie Ihr Projekt auf ein Git Repo hochladen? –
kann ich nicht. aber das Problem, das ich habe, ist, kann ich "AuthenticationService" in Anbietern nicht registrieren. Ich habe ein neues Projekt gestartet, dann habe ich den Dienst hinzugefügt und versucht, ihn zu registrieren. Ich versuche nicht einmal, es in einer anderen Komponente zu verwenden. – Hanoch