當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。