feat(facade): add read/write access to global variables
This commit is contained in:
parent
75578f41e7
commit
cdf791f0c5
15
modules/angular2/src/facade/js_interop.dart
Normal file
15
modules/angular2/src/facade/js_interop.dart
Normal file
@ -0,0 +1,15 @@
|
|||||||
|
library angular2.src.facade.js_interop;
|
||||||
|
|
||||||
|
import 'dart:js' as js;
|
||||||
|
|
||||||
|
setGlobalVar(String name, value) {
|
||||||
|
js.context[name] = value;
|
||||||
|
}
|
||||||
|
|
||||||
|
getGlobalVar(String name) {
|
||||||
|
return js.context[name];
|
||||||
|
}
|
||||||
|
|
||||||
|
invokeJsFunction(js.JsFunction fn, self, args) {
|
||||||
|
return fn.apply(args, thisArg: self);
|
||||||
|
}
|
13
modules/angular2/src/facade/js_interop.ts
Normal file
13
modules/angular2/src/facade/js_interop.ts
Normal file
@ -0,0 +1,13 @@
|
|||||||
|
import {global} from './lang';
|
||||||
|
|
||||||
|
export function setGlobalVar(name: string, value: any) {
|
||||||
|
global[name] = value;
|
||||||
|
}
|
||||||
|
|
||||||
|
export function getGlobalVar(name: string) {
|
||||||
|
return global[name];
|
||||||
|
}
|
||||||
|
|
||||||
|
export function invokeJsFunction(fn: Function, self: any, args: List<any>) {
|
||||||
|
return fn.apply(self, args);
|
||||||
|
}
|
Loading…
x
Reference in New Issue
Block a user