Skip to content

Instantly share code, notes, and snippets.

@mhartington
Last active December 17, 2015 14:50
Show Gist options
  • Save mhartington/227f74e92b0612ab2144 to your computer and use it in GitHub Desktop.
Save mhartington/227f74e92b0612ab2144 to your computer and use it in GitHub Desktop.
export class MyClass {
  // Here we're injecting the http service and our own data service
  constructor(http: Http, data:Data){
    this. http = http;
    this.data = data;
    // Here we have to create our own this. reference
  }
}
export class MyClass {
  // Here we're injecting the http service and our own data service
  constructor(
    public http: Http, 
    public data:Data){
    // Now we don't need to add this. 
    // the Public keyword tells typescript 
    // that these are available through out the class as 
    // this.http and this.data
  }
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment