I am trying to understand how a private variable is called in the official Angular 2 http tutorial
In the section above, there is a file called app/toh/hero.service.ts , which (basically):
@Injectable() export class HeroService { constructor (private http: Http) {} private _heroesUrl = 'app/heroes'; getHeroes () { return this.http.get(this._heroesUrl) .map(res => <Hero[]> res.json().data) .catch(this.handleError); } private handleError (error: Response) {
There is a personal variable _heroesUrl . So, there is a convention for running private variables and underlined methods.
But why is the underscore not used for private http and private handleError ? Is it just a typo or is it a reason for this?
EricC source share