当前位置: 首页>>代码示例>>TypeScript>>正文


TypeScript Injector.resolveAndCreate方法代码示例

本文整理汇总了TypeScript中angular2/core.Injector.resolveAndCreate方法的典型用法代码示例。如果您正苦于以下问题:TypeScript Injector.resolveAndCreate方法的具体用法?TypeScript Injector.resolveAndCreate怎么用?TypeScript Injector.resolveAndCreate使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在angular2/core.Injector的用法示例。


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

示例1: beforeEach

  beforeEach(function() {
    routeSet$ = new Subject<NextInstruction>();
    spyOn(router, 'replace');
    spyOn(observer, 'next');
    const injector = Injector.resolveAndCreate([
      provide(Router, { useValue: router })
    ]);

    redirect = injector.resolveAndInstantiate(redirectMiddleware);
  });
开发者ID:danielsef,项目名称:router,代码行数:10,代码来源:redirect.spec.ts

示例2: beforeEach

 beforeEach(() => {
   var injector = Injector.resolveAndCreate(
       [provide(ResponseOptions, {useClass: BaseResponseOptions}), MockBackend]);
   backend = injector.get(MockBackend);
   var base = new BaseRequestOptions();
   sampleRequest1 = new Request(base.merge(new RequestOptions({url: 'https://google.com'})));
   sampleResponse1 = new Response(new ResponseOptions({body: 'response1'}));
   sampleRequest2 = new Request(base.merge(new RequestOptions({url: 'https://google.com'})));
   sampleResponse2 = new Response(new ResponseOptions({body: 'response2'}));
 });
开发者ID:hankduan,项目名称:angular,代码行数:10,代码来源:mock_backend_spec.ts

示例3: beforeEach

 beforeEach(() => {
     injector = Injector.resolveAndCreate([
         HTTP_PROVIDERS,
         GithubComponent,
         GithubService,
         Config
     ]);
     component = injector.get(GithubComponent);
     service = injector.get(GithubService);
     sinon.spy(service, "searchRepositories");
 });
开发者ID:tomastrajan,项目名称:complete-angular2-seed,代码行数:11,代码来源:github-component-integration-test.ts

示例4:

    //nextRoute, CurrentRoute instructions
    (nextInstr: any, currInstr: any) => {
      //We’re first asking the Injector class to give us a concrete injector that is aware of only once class: AuthService.
      let injector: any = Injector.resolveAndCreate([AuthService]);

      //Next, we’re asking this injector to give us an instance of that class.
      let authService: AuthService = injector.get(AuthService);

      console.log('nextInstr', nextInstr);
      console.log('currInstr', currInstr);
      return authService.isLogged();
    }
开发者ID:spencersmb,项目名称:ng2book-routes,代码行数:12,代码来源:ProtectedComponent.ts

示例5: createStore

  function createStore(reducer, monitorReducer = T => T){
    const injector = Injector.resolveAndCreate([
      provideStore(reducer),
      instrumentStore(monitorReducer)
    ]);

    const store = injector.get(Store);
    const devtools = injector.get(StoreDevtools);

    return { store, devtools };
  }
开发者ID:MarkPieszak,项目名称:devtools,代码行数:11,代码来源:store_spec.ts

示例6: inject

 return inject(tokens, (tcb, router, location, backend, userService, loginService) => {
   // TODO it's not a good idea, but I have no other way.
   // It must be resolved in https://github.com/angular/angular/issues/4112
   appInjector(Injector.resolveAndCreate([
     provide(UserService, {useValue: userService}),
     provide(LoginService, {useValue: loginService}),
     provide(Router, {useValue: router}),
   ]));
   const ctx = new TestContext({tcb, router, location, backend});
   fn(ctx);
 });
开发者ID:gtostock,项目名称:angular2-app,代码行数:11,代码来源:TestContext.ts

示例7: it

  it('should alias devtools to the store backend', () => {
    const injector = Injector.resolveAndCreate([
      provideStore(counter),
      instrumentStore()
    ]);

    const devtools = injector.get(StoreDevtools);
    const backend = injector.get(StoreBackend);

    expect(devtools).toBe(backend);
  });
开发者ID:MarkPieszak,项目名称:devtools,代码行数:11,代码来源:store_spec.ts

示例8: value

 function value(snapshot: FirebaseDataSnapshot) {
   let child = snapshot.val();
   child[keyFieldName] = snapshot.key();
   if (type && Ng2Firebase.appRef) {
     let providers = [provide(FirebaseData, {useValue: child})];
     let injector = Ng2Firebase.appRef.injector;
     if (!opts.load) injector = Injector.resolveAndCreate([]);
     let childInjector = injector.resolveAndCreateChild(providers);
     child = childInjector.resolveAndInstantiate(type);
   }
   observer.next(child);
 }
开发者ID:tpadjen,项目名称:ng2-firebase-observables,代码行数:12,代码来源:ng2-firebase.ts

示例9: beforeEach

 beforeEach(() => {
     injector = Injector.resolveAndCreate([
         HTTP_PROVIDERS,
         // Provide a mocked (fake) backend for Http
         provide(XHRBackend, {useClass: MockBackend}),
         TranslateService
     ]);
     backend = injector.get(XHRBackend);
     translate = injector.get(TranslateService);
     // sets the connection when someone tries to access the backend with an xhr request
     backend.connections.subscribe((c: MockConnection) => connection = c);
 });
开发者ID:teyosh,项目名称:ng2-translate,代码行数:12,代码来源:translate.service.spec.ts

示例10: beforeEach

    beforeEach(() => {
        injector = Injector.resolveAndCreate([
            HTTP_PROVIDERS,
            MockBackend,
            provide(XHRBackend, {useClass: MockBackend}),
            First
        ]);

        mockBackend = injector.get(MockBackend);
        backend = injector.get(XHRBackend);
        httpService = injector.get(Http);
        _first = injector.get(First);
    });
开发者ID:gsopu8065,项目名称:angular2Seed,代码行数:13,代码来源:first.spec.ts


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