I'm trying to make a request with angular5 for learning purposes and I'm not with you, follow the console log and the source code.
ERROR Error: Uncaught (in promise): Error: StaticInjectorError[InvestimentosService]:
StaticInjectorError[InvestimentosService]:
NullInjectorError: No provider for InvestimentosService!
Error: StaticInjectorError[InvestimentosService]:
StaticInjectorError[InvestimentosService]:
NullInjectorError: No provider for InvestimentosService!
at _NullInjector.get (core.js:923)
at resolveToken (core.js:1211)
at tryResolveToken (core.js:1153)
at StaticInjector.get (core.js:1024)
at resolveToken (core.js:1211)
at tryResolveToken (core.js:1153)
at StaticInjector.get (core.js:1024)
at resolveNgModuleDep (core.js:10585)
at NgModuleRef_.get (core.js:11806)
at resolveNgModuleDep (core.js:10585)
at _NullInjector.get (core.js:923)
at resolveToken (core.js:1211)
at tryResolveToken (core.js:1153)
at StaticInjector.get (core.js:1024)
at resolveToken (core.js:1211)
at tryResolveToken (core.js:1153)
at StaticInjector.get (core.js:1024)
at resolveNgModuleDep (core.js:10585)
at NgModuleRef_.get (core.js:11806)
at resolveNgModuleDep (core.js:10585)
at resolvePromise (zone.js:824)
at resolvePromise (zone.js:795)
at eval (zone.js:873)
at ZoneDelegate.invokeTask (zone.js:425)
at Object.onInvokeTask (core.js:4620)
at ZoneDelegate.invokeTask (zone.js:424)
at Zone.runTask (zone.js:192)
at drainMicroTaskQueue (zone.js:602)
at ZoneTask.invokeTask [as invoke] (zone.js:503)
at invokeTask (zone.js:1540)
Follow the codes
inversiones.component.ts
import { Component, OnInit } from '@angular/core';
import { FormBuilder, FormGroup, Validators } from '@angular/forms'
import { InvestimentosService } from './investimentos.services'
import { Investimentos } from './investimentos.model'
// import 'rxjs/add/observable/from'
// import { Observable } from "rxjs/Observable";
@Component({
selector: 'app-investimentos',
templateUrl: './investimentos.component.html',
styleUrls: ['./investimentos.component.css']
})
export class InvestimentosComponent implements OnInit {
Form: FormGroup
namberPattern = /^[+-]?([0-9]*[.])?[0-9]+$/
porcentagemDoSeuSELICAno: number
porcentagemDoSeuSELICMes: number
// valordoJurosSelic:number
arSelics: any[] = []
arCdis: any[] = []
arPoupancas: any[] = []
taxas: Investimentos
constructor(private fb: FormBuilder, private investimentosService: InvestimentosService) { }
ngOnInit() {
this.investimentosService.taxas()
.subscribe(taxas => this.taxas = taxas)
}
}
investments.model.ts
export interface Investimentos {
selic: string
cdi: string
}
inversiones.services.ts
import { Injectable } from '@angular/core'
import { HttpClient,HttpParams } from '@angular/common/http'
import { Observable } from 'rxjs/Observable'
import 'rxjs/add/operator/map'
import 'rxjs/add/operator/catch'
import { Investimentos } from "./investimentos.model"
@Injectable()
export class InvestimentosService {
constructor(private http: HttpClient) { }
taxas(): Observable<Investimentos> {
return this.http.get<Investimentos>('http://localhost:8080/aeua/cora/particular/all/backend/index.php')
}
}