本文整理汇总了TypeScript中angular2/src/dom/browser_adapter.BrowserDomAdapter.makeCurrent方法的典型用法代码示例。如果您正苦于以下问题:TypeScript BrowserDomAdapter.makeCurrent方法的具体用法?TypeScript BrowserDomAdapter.makeCurrent怎么用?TypeScript BrowserDomAdapter.makeCurrent使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类angular2/src/dom/browser_adapter.BrowserDomAdapter
的用法示例。
在下文中一共展示了BrowserDomAdapter.makeCurrent方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的TypeScript代码示例。
示例1: createInjector
export function createInjector(zone: NgZone, bus: MessageBus): Injector {
BrowserDomAdapter.makeCurrent();
_rootBindings.push(bind(NgZone).toValue(zone));
_rootBindings.push(bind(MessageBus).toValue(bus));
var injector: Injector = Injector.resolveAndCreate(_rootBindings);
return injector.resolveAndCreateChild(_injectorBindings());
}
示例2: bootstrap
export function bootstrap(appComponentType: Type,
componentInjectableBindings: List<Type | Binding | List<any>> = null,
errorReporter: Function = null): Promise<ApplicationRef> {
BrowserDomAdapter.makeCurrent();
var bootstrapProcess = PromiseWrapper.completer();
var zone = _createNgZone(errorReporter);
zone.run(() => {
// TODO(rado): prepopulate template cache, so applications with only
// index.html and main.js are possible.
var appInjector = _createAppInjector(appComponentType, componentInjectableBindings, zone);
var compRefToken: Promise<any> =
PromiseWrapper.wrap(() => appInjector.get(appComponentRefToken));
var tick = (componentRef) => {
var appChangeDetector = internalView(componentRef.hostView).changeDetector;
// retrieve life cycle: may have already been created if injected in root component
var lc = appInjector.get(LifeCycle);
lc.registerWith(zone, appChangeDetector);
lc.tick(); // the first tick that will bootstrap the app
bootstrapProcess.resolve(new ApplicationRef(componentRef, appComponentType, appInjector));
};
PromiseWrapper.then(compRefToken, tick,
(err, stackTrace) => {bootstrapProcess.reject(err, stackTrace)});
});
return bootstrapProcess.promise;
}
示例3: main
export function main() {
BrowserDomAdapter.makeCurrent();
var iterations = getIntParameter('iterations');
reflector.reflectionCapabilities = new ReflectionCapabilities();
var appInjector = Injector.resolveAndCreate([]);
var bindings = [
DirectiveBinding.createFromType(A, null),
DirectiveBinding.createFromType(B, null),
DirectiveBinding.createFromType(C, null)
];
var proto = ProtoElementInjector.create(null, 0, bindings, false, 0);
var elementInjector = proto.instantiate(null);
function instantiate() {
for (var i = 0; i < iterations; ++i) {
var ei = proto.instantiate(null);
ei.hydrate(appInjector, null, null);
}
}
function hydrate() {
for (var i = 0; i < iterations; ++i) {
elementInjector.dehydrate();
elementInjector.hydrate(appInjector, null, null);
}
}
bindAction('#instantiate', () => microBenchmark('instantiateAvg', iterations, instantiate));
bindAction('#hydrate', () => microBenchmark('instantiateAvg', iterations, hydrate));
}
示例4: bootstrap
export function bootstrap(appComponentType: Type,
componentInjectableBindings: List<Binding> = null,
errorReporter: Function = null): Promise<ComponentRef> {
BrowserDomAdapter.makeCurrent();
var bootstrapProcess = PromiseWrapper.completer();
var zone = _createVmZone(errorReporter);
zone.run(() => {
// TODO(rado): prepopulate template cache, so applications with only
// index.html and main.js are possible.
var appInjector = _createAppInjector(appComponentType, componentInjectableBindings, zone);
PromiseWrapper.then(appInjector.asyncGet(appComponentRefToken),
(componentRef) => {
var appChangeDetector = componentRef.hostView.changeDetector;
// retrieve life cycle: may have already been created if injected in root component
var lc = appInjector.get(LifeCycle);
lc.registerWith(zone, appChangeDetector);
lc.tick(); //the first tick that will bootstrap the app
bootstrapProcess.resolve(componentRef);
},
(err) => {
bootstrapProcess.reject(err)
});
});
return bootstrapProcess.promise;
}
示例5: bootstrapUICommon
export function bootstrapUICommon(bus: MessageBus) {
BrowserDomAdapter.makeCurrent();
var zone = createNgZone();
wtfInit();
zone.run(() => {
var injector = createInjector(zone);
var webWorkerMain = injector.get(WebWorkerMain);
webWorkerMain.attachToWebWorker(bus);
});
}
示例6: bootstrapUICommon
export function bootstrapUICommon(bus: MessageBus) {
BrowserDomAdapter.makeCurrent();
var zone = createNgZone();
wtfInit();
zone.run(() => {
var injector = createInjector(zone, bus);
// necessary to kick off all the message based components
injector.get(WebWorkerMain);
});
}
示例7: commonBootstrap
export function commonBootstrap(
appComponentType: /*Type*/ any,
componentInjectableBindings: List<Type | Binding | List<any>> = null): Promise<ApplicationRef> {
BrowserDomAdapter.makeCurrent();
wtfInit();
var bootstrapProcess = PromiseWrapper.completer();
var zone = createNgZone();
zone.run(() => {
var exceptionHandler;
try {
var appInjector = _createAppInjector(appComponentType, componentInjectableBindings, zone);
exceptionHandler = appInjector.get(ExceptionHandler);
zone.overrideOnErrorHandler((e, s) => exceptionHandler.call(e, s));
var compRefToken: Promise<any> = appInjector.get(appComponentRefPromiseToken);
var tick = (componentRef) => {
var appChangeDetector = internalView(componentRef.hostView).changeDetector;
// retrieve life cycle: may have already been created if injected in root component
var lc = appInjector.get(LifeCycle);
lc.registerWith(zone, appChangeDetector);
lc.tick(); // the first tick that will bootstrap the app
bootstrapProcess.resolve(new ApplicationRef(componentRef, appComponentType, appInjector));
};
var tickResult = PromiseWrapper.then(compRefToken, tick);
PromiseWrapper.then(tickResult,
(_) => {}); // required for Dart to trigger the default error handler
PromiseWrapper.then(tickResult, null,
(err, stackTrace) => { bootstrapProcess.reject(err, stackTrace); });
} catch (e) {
if (isPresent(exceptionHandler)) {
exceptionHandler.call(e, e.stack);
} else {
// The error happened during the creation of an injector, most likely because of a bug in
// DI.
// We cannot use the provided exception handler, so we default to writing to the DOM.
DOM.logError(e);
}
bootstrapProcess.reject(e, e.stack);
}
});
return bootstrapProcess.promise;
}
示例8: main
export function main() {
BrowserDomAdapter.makeCurrent();
var count = getIntParameter('selectors');
var fixedMatcher;
var fixedSelectorStrings = [];
var fixedSelectors = [];
for (var i = 0; i < count; i++) {
ListWrapper.push(fixedSelectorStrings, randomSelector());
}
for (var i = 0; i < count; i++) {
ListWrapper.push(fixedSelectors, CssSelector.parse(fixedSelectorStrings[i]));
}
fixedMatcher = new SelectorMatcher();
for (var i = 0; i < count; i++) {
fixedMatcher.addSelectables(fixedSelectors[i], i);
}
function parse() {
var result = [];
for (var i = 0; i < count; i++) {
ListWrapper.push(result, CssSelector.parse(fixedSelectorStrings[i]));
}
return result;
}
function addSelectable() {
var matcher = new SelectorMatcher();
for (var i = 0; i < count; i++) {
matcher.addSelectables(fixedSelectors[i], i);
}
return matcher;
}
function match() {
var matchCount = 0;
for (var i = 0; i < count; i++) {
fixedMatcher.match(fixedSelectors[i][0], (selector, selected) => { matchCount += selected; });
}
return matchCount;
}
bindAction('#parse', parse);
bindAction('#addSelectable', addSelectable);
bindAction('#match', match);
}
示例9: bootstrap
export function bootstrap(appComponentType, componentServiceBindings = null, errorReporter = null) {
BrowserDomAdapter.makeCurrent();
var bootstrapProcess = PromiseWrapper.completer();
var zone = _createVmZone(errorReporter);
zone.run(() => {
var appInjector = _createAppInjector(appComponentType, componentServiceBindings, zone);
PromiseWrapper.then(appInjector.asyncGet(appViewToken), (rootView) => {
var lc = appInjector.get(LifeCycle);
lc.registerWith(zone, rootView.changeDetector);
lc.tick();
bootstrapProcess.resolve(appInjector);
}, (err) => {
bootstrapProcess.reject(err);
});
});
return bootstrapProcess.promise;
}
示例10:
/// <reference path="../../typings/tsd.d.ts" />
/// <reference path="../custom_typings/ng2.d.ts" />
import {BrowserDomAdapter} from 'angular2/src/dom/browser_adapter';
BrowserDomAdapter.makeCurrent();