Skip to content

Instantly share code, notes, and snippets.

@ctran
Created May 14, 2016 06:50
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ctran/97247c30189237b814544cba47dff1cd to your computer and use it in GitHub Desktop.
Save ctran/97247c30189237b814544cba47dff1cd to your computer and use it in GitHub Desktop.
Ionic2 - Global Var
@App({
providers: [GlobalService], // constructed once
config: {}
})
class MyApp {
}
import {Injectable} from 'angular2/core';
import {Http, Headers} from 'angular2/http';
@Injectable()
export class GlobalService {
constructor(private http: Http) {
}
}
@Page({
})
export class SpecialsPage {
// shared instance being injected
constructor(private global: GlobalService) {
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment