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

TypeScript di.bind函数代码示例

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

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



在下文中一共展示了bind函数的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的TypeScript代码示例。

示例1: inject

 inject([AsyncTestCompleter], (async) => {
   bootstrap(HierarchyAppCmp, [testBindings, bind(appBaseHrefToken).toValue('/my/app')])
       .then((applicationRef) => {
         var router = applicationRef.hostComponent.router;
         router.subscribe((_) => {
           expect(el).toHaveText('root { parent { hello } }');
           expect(applicationRef.hostComponent.location.path())
               .toEqual('/my/app/parent/child');
           async.done();
         });
         router.navigate('/parent/child');
       });
 }));
开发者ID:Salim-K,项目名称:angular,代码行数:13,代码来源:router_integration_spec.ts


示例2: _getAppBindings

function _getAppBindings() {
  var appDoc;
  try {
    appDoc = DOM.defaultDoc();
  } catch (e) {
    appDoc = null;
  }
  return [bind(appDocumentToken).toValue(appDoc), bind(ShadowDomStrategy).toFactory((styleUrlResolver, doc) => new EmulatedUnscopedShadowDomStrategy(styleUrlResolver, doc.head), [StyleUrlResolver, appDocumentToken]), Compiler, CompilerCache, bind(TemplateResolver).toClass(MockTemplateResolver), bind(ChangeDetection).toValue(dynamicChangeDetection), TemplateLoader, DirectiveMetadataReader, Parser, Lexer, ExceptionHandler, bind(XHR).toClass(MockXHR), ComponentUrlMapper, UrlResolver, StyleUrlResolver, StyleInliner, TestBed, bind(VmTurnZone).toClass(MockVmTurnZone), bind(EventManager).toFactory((zone) => {
    var plugins = [new DomEventsPlugin()];
    return new EventManager(plugins, zone);
  }, [VmTurnZone])];
}
开发者ID:gdi2290,项目名称:sample-Angular2,代码行数:12,代码来源:test_injector.ts


示例3: bindTo

 static bindTo(childTokens): List<Binding> {
   return [
     bind(_CHILDREN)
         .toAsyncFactory((injector) => PromiseWrapper.all(
                             ListWrapper.map(childTokens, (token) => injector.asyncGet(token))),
                         [Injector]),
     bind(WebDriverExtension)
         .toFactory(
             (children, capabilities) => {
               var delegate;
               ListWrapper.forEach(children, (extension) => {
                 if (extension.supports(capabilities)) {
                   delegate = extension;
                 }
               });
               if (isBlank(delegate)) {
                 throw new BaseException('Could not find a delegate for given capabilities!');
               }
               return delegate;
             },
             [_CHILDREN, Options.CAPABILITIES])
   ];
 }
开发者ID:AsherBarak,项目名称:angular,代码行数:23,代码来源:web_driver_extension.ts


示例4: beforeEach

 beforeEach(() => {
   injector = Injector.resolveAndCreate([
     BaseRequestOptions,
     MockBackend,
     bind(Http).toFactory(
         function(backend: ConnectionBackend, defaultOptions: BaseRequestOptions) {
           return new Http(backend, defaultOptions);
         },
         [MockBackend, BaseRequestOptions])
   ]);
   http = injector.get(Http);
   backend = injector.get(MockBackend);
   baseResponse = new Response(new ResponseOptions({body: 'base response'}));
 });
开发者ID:cedriclam,项目名称:angular,代码行数:14,代码来源:http_spec.ts


示例5: jsmFn

 jsmFn(name, function(done) {
   var async = false;
   var completerBinding = bind(AsyncTestCompleter).toFactory(() => {
     if (!inIt)
       throw new Error('AsyncTestCompleter can only be injected in an "it()"');
     async = true;
     return new AsyncTestCompleter(done);
   });
   var injector = createTestInjector([...testBindings, completerBinding]);
   runner.run(injector);
   if (!(fn instanceof FunctionWithParamTokens)) {
     fn = inject([], fn);
   }
   inIt = true;
   fn.execute(injector);
   inIt = false;
   if (!async)
     done();
 });
开发者ID:gdi2290,项目名称:sample-Angular2,代码行数:19,代码来源:test_lib.ts


示例6: _getAppBindings

/**
 * Returns the application injector bindings.
 *
 * This must be kept in sync with _injectorBindings() in application.js
 *
 * @returns {any[]}
 */
function _getAppBindings() {
  var appDoc;

  // The document is only available in browser environment
  try {
    appDoc = DOM.defaultDoc();
  } catch (e) {
    appDoc = null;
  }
  return [
    bind(DOCUMENT_TOKEN)
        .toValue(appDoc),
    bind(ShadowDomStrategy)
        .toFactory((styleUrlResolver, doc) =>
                           new EmulatedUnscopedShadowDomStrategy(styleUrlResolver, doc.head),
                   [StyleUrlResolver, DOCUMENT_TOKEN]),
    DomRenderer,
    DefaultDomCompiler,
    bind(Renderer).toAlias(DomRenderer),
    bind(RenderCompiler).toAlias(DefaultDomCompiler),
    ProtoViewFactory,
    AppViewPool,
    AppViewManager,
    AppViewManagerUtils,
    ELEMENT_PROBE_CONFIG,
    bind(APP_VIEW_POOL_CAPACITY).toValue(500),
    Compiler,
    CompilerCache,
    bind(TemplateResolver).toClass(MockTemplateResolver),
    bind(PipeRegistry).toValue(defaultPipeRegistry),
    bind(ChangeDetection).toClass(DynamicChangeDetection),
    TemplateLoader,
    DynamicComponentLoader,
    DirectiveResolver,
    Parser,
    Lexer,
    ExceptionHandler,
    bind(XHR).toClass(MockXHR),
    ComponentUrlMapper,
    UrlResolver,
    StyleUrlResolver,
    StyleInliner,
    TestBed,
    TestComponentBuilder,
    bind(NgZone).toClass(MockNgZone),
    bind(EventManager)
        .toFactory(
            (zone) => {
              var plugins = [
                new DomEventsPlugin(),
              ];
              return new EventManager(plugins, zone);
            },
            [NgZone]),
  ];
}
开发者ID:Mariem-07,项目名称:angular,代码行数:63,代码来源:test_injector.ts


示例7: bind

 * #Example
 *
 * ```
 * import {HTTP_BINDINGS, Http} from 'http/http';
 * @Component({selector: 'http-app', viewBindings: [HTTP_BINDINGS]})
 * @View({template: '{{data}}'})
 * class MyApp {
 *   constructor(http:Http) {
 *     http.request('data.txt').subscribe(res => this.data = res.text());
 *   }
 * }
 * ```
 *
 */
export const HTTP_BINDINGS: List<any> = [
  bind(ConnectionBackend)
      .toClass(XHRBackend),
  BrowserXhr,
  bind(RequestOptions).toClass(BaseRequestOptions),
  bind(ResponseOptions).toClass(BaseResponseOptions),
  Http
];

export const JSONP_BINDINGS: List<any> = [
  bind(ConnectionBackend)
      .toClass(JSONPBackend),
  BrowserJsonp,
  bind(RequestOptions).toClass(BaseRequestOptions),
  bind(ResponseOptions).toClass(BaseResponseOptions),
  Jsonp
];
开发者ID:synaptek,项目名称:angular,代码行数:31,代码来源:http.ts


示例8: hasNativeShadowDom

import {
  ShadowDomStrategy,
  NativeShadowDomStrategy,
  EmulatedScopedShadowDomStrategy,
  EmulatedUnscopedShadowDomStrategy
} from 'angular2/render';
import {bind} from 'angular2/di';
import {document} from 'angular2/src/facade/browser';
import {DOCUMENT_TOKEN} from 'angular2/src/render/dom/dom_renderer';

export function hasNativeShadowDom() {
  return Boolean(document && document.body && document.body.createShadowRoot);
}

export var emulatedScopedShadowDomInjectables = [
  bind(ShadowDomStrategy).toFactory((doc) => {
    return new EmulatedScopedShadowDomStrategy(doc.body);
  }, [DOCUMENT_TOKEN])
];

// use EmulatedScope if Native is not supported
export var nativeShadowDomInjectables = hasNativeShadowDom() ? [
    bind(ShadowDomStrategy).toClass(NativeShadowDomStrategy)
  ] : emulatedScopedShadowDomInjectables;

export var emulatedUnscopedShadowDomInjectables = [
  bind(ShadowDomStrategy).toFactory((doc) => {
    return new EmulatedUnscopedShadowDomStrategy(doc.body);
  }, [DOCUMENT_TOKEN])
];
开发者ID:SekibOmazic,项目名称:angular2-rx,代码行数:30,代码来源:shadowDomInjectables.ts


示例9: _injectorBindings

import {AppViewPool, APP_VIEW_POOL_CAPACITY} from 'angular2/src/core/compiler/view_pool';
import {AppViewManager} from 'angular2/src/core/compiler/view_manager';
import {AppViewManagerUtils} from 'angular2/src/core/compiler/view_manager_utils';
import {AppViewListener} from 'angular2/src/core/compiler/view_listener';
import {ProtoViewFactory} from 'angular2/src/core/compiler/proto_view_factory';
import {Renderer, RenderCompiler} from 'angular2/src/render/api';
import {DomRenderer, DOCUMENT_TOKEN} from 'angular2/src/render/dom/dom_renderer';
import {DefaultDomCompiler} from 'angular2/src/render/dom/compiler/compiler';
import {internalView} from 'angular2/src/core/compiler/view_ref';

import {appComponentRefToken, appComponentTypeToken} from './application_tokens';

var _rootInjector: Injector;

// Contains everything that is safe to share between applications.
var _rootBindings = [bind(Reflector).toValue(reflector), TestabilityRegistry];

function _injectorBindings(appComponentType): List<Type | Binding | List<any>> {
  var bestChangeDetection: Type = DynamicChangeDetection;
  if (PreGeneratedChangeDetection.isSupported()) {
    bestChangeDetection = PreGeneratedChangeDetection;
  } else if (JitChangeDetection.isSupported()) {
    bestChangeDetection = JitChangeDetection;
  }
  return [
    bind(DOCUMENT_TOKEN)
        .toValue(DOM.defaultDoc()),
    bind(appComponentTypeToken).toValue(appComponentType),
    bind(appComponentRefToken)
        .toFactory(
            (dynamicComponentLoader, injector, testability, registry) => {
开发者ID:cedriclam,项目名称:angular,代码行数:31,代码来源:application.ts


示例10: Boolean

/// <reference path="../../typings/tsd.d.ts" />
/// <reference path="../custom_typings/ng2.d.ts" />
import {ShadowDomStrategy, NativeShadowDomStrategy} from 'angular2/core';
import {StyleUrlResolver} from 'angular2/src/render/dom/shadow_dom/style_url_resolver';
import {bind} from 'angular2/di';
import {document} from 'angular2/src/facade/browser';

export var hasShadowDom = Boolean(document && document.body && document.body.createShadowRoot);

export var shadowDomInjectables = [
  (!hasShadowDom) ? [] :
  bind(ShadowDomStrategy).toFactory(
    styleUrlResolver => new NativeShadowDomStrategy(styleUrlResolver),
    [StyleUrlResolver]
  )
]
开发者ID:StanShumsky,项目名称:angular2-webpack-starter,代码行数:16,代码来源:checkIfShadowDom.ts



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


鲜花

握手

雷人

路过

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

请发表评论

全部评论

专题导读
上一篇:
TypeScript di.forwardRef函数代码示例发布时间:2022-05-25
下一篇:
TypeScript testing.tick函数代码示例发布时间: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