such as
getHeroes (): Observable < Hero [] > {
return this.http.get < Hero [] > (this.heroesUrl)
}
can I just write it this way?
getHeroes () {
return this.http.get < Hero [] > (this.heroesUrl)
}
is it necessary to give < Hero [] > after get? What"s the point?
I see that some code will get the data of the json class from an api
and then write directly:
private headers = new HttpHeaders (). Set ("Content-Type"," application/json");
/ / does not provide the return of the function and does not give anything after the get
getHeroes () {
return this.http.get (this.myurl, {headers:this.headers})
}
is it because the data types to be accepted are not defined in angular in advance?
Thank you for answering!