-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathng1Bridge.ts
More file actions
29 lines (23 loc) · 733 Bytes
/
Copy pathng1Bridge.ts
File metadata and controls
29 lines (23 loc) · 733 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
import {Injectable} from 'angular2/core';
import { BrowserDomAdapter } from 'angular2/platform/browser'
//trick to get angular global reference on js.
declare var angular:any;
@Injectable()
export class Ng1Bridge {
constructor()
{
this._dom = new BrowserDomAdapter();
this._body = this._dom.query("body");
this._injector = angular.element(this._body).injector();
this._globalScope = angular.element(this._body).scope();
}
get injector():any {
return this._injector;
}
getService(name:string):any {
return (name !== null || name !== '') ? this._injector.get(name) : null; //todo: should throw an Excpetion. Name is required.
}
get globalScope():any {
return this._globalScope;
}
}