When it comes to using services in components and other services, I have noticed two common approaches. One popular example is the Http
service, which is imported in both cases:
import { Http } from '@angular/http';
Approach 1:
constructor ( private http: Http ) {
this.http = http;
}
Approach 2:
constructor ( private http: Http ) { }
In both scenarios, the Http
service is accessible via this.http
.
Is there a benefit to using approach 1 over approach 2? Could it be related to multiple instantiations?