• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

TypeScript browser_adapter.BrowserDomAdapter类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了TypeScript中angular2/src/dom/browser_adapter.BrowserDomAdapter的典型用法代码示例。如果您正苦于以下问题:TypeScript BrowserDomAdapter类的具体用法?TypeScript BrowserDomAdapter怎么用?TypeScript BrowserDomAdapter使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



在下文中一共展示了BrowserDomAdapter类的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());
}
开发者ID:KenWilliamson,项目名称:Angular2HostedMobileApp,代码行数:7,代码来源:di_bindings.ts


示例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;
}
开发者ID:cedriclam,项目名称:angular,代码行数:29,代码来源:application.ts


示例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));
}
开发者ID:B-Thapa,项目名称:angular,代码行数:32,代码来源:element_injector_benchmark.ts


示例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;
}
开发者ID:tavwizard,项目名称:angular,代码行数:31,代码来源:application.ts


示例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);
  });
}
开发者ID:goderbauer,项目名称:angular,代码行数:10,代码来源:impl.ts


示例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);
  });
}
开发者ID:KenWilliamson,项目名称:Angular2HostedMobileApp,代码行数:10,代码来源:impl.ts


示例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;
}
开发者ID:goderbauer,项目名称:angular,代码行数:47,代码来源:application_common.ts


示例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);
}
开发者ID:B-Thapa,项目名称:angular,代码行数:46,代码来源:selector_benchmark.ts


示例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;
}
开发者ID:gdi2290,项目名称:sample-Angular2,代码行数:17,代码来源:application.ts


示例10: getStringParameter

export function getStringParameter(name) {
  var els = DOM.querySelectorAll(document, `input[name="${name}"]`);
  var value;
  var el;
  for (var i = 0; i < els.length; i++) {
    el = els[i];
    var type = DOM.type(el);
    if ((type != 'radio' && type != 'checkbox') || DOM.getChecked(el)) {
      value = DOM.getValue(el);
      break;
    }
  }
  if (isBlank(value)) {
    throw new BaseException(`Could not find and input field with name ${name}`);
  }
  return value;
}
开发者ID:gdi2290,项目名称:sample-Angular2,代码行数:17,代码来源:benchmark_util.ts



注:本文中的angular2/src/dom/browser_adapter.BrowserDomAdapter类示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
TypeScript dom_adapter.DOM类代码示例发布时间:2022-05-25
下一篇:
TypeScript vm_turn_zone.VmTurnZone类代码示例发布时间:2022-05-25
热门推荐
热门话题
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap