What is different between putting @Inject and without putting @Inject?


#1

I was wondering what is different between putting @Inject in front and without putting the @Inject? Please find bellow the 2 block of code:

//With @Inject
import {Inject} from 'angular2/core';
import {Http} from 'angular2/http';

export class MyApp {
  constructor(@Inject(Http) http) {
    this.http = http;
  }
  ...
}

Without @Inject

//Without @Inject
import {Http} from 'angular2/http';

export class MyApp {
  constructor(Http http) {
    this.http = http;
  }
  ...
}

#2

I found the answer, the 2nd script, it is TypeScript, so it handles the Dependency Injection, so you don’t need to put @Inject. :slightly_smiling:


#3

Yep, you will use @Inject if you write something like services in angularjs 1. So you want to use the angular dependency injection then :slight_smile: