Good.
I currently have a view, from which I retrieve data that I pass to a component that calls a service. The data passes from the view to the component function through the click event without any problem. But when it goes to call the service function it shows an error that the property is undefined.
View:
<input #search type="text" ng-model="search">
<button (click)="searchIt(search.value)" class="button is-primary">Search</button>
Component function:
searchIt(id: string){
this.myService.getIt(id)
.subscribe(
res => {
this.content = res;
},
err => {
console.log(err);
}
);
}
Function of the service (although it does not even call it):
getIt(id: string): Observable<content[]>{
console.log("Servicio: " + key);
return this.http.get(this.url + "/" + id)
.map(res => res.json())
.catch((error:any) => Observable.throw(error.json().error || 'Server error'));
};
Let's see if someone can help me.
You have to inject the service.
and you refer to the service
I have a similar problem but in my case I am almost injecting the service well, what do you think it could be??? I'm using angular 10 and it stopped working from one day to the next, I've already rolled back so far before implementing it and the same problem continues, I know this question is a bit old but well I hope you can support me greetings