當前位置: 首頁>>代碼示例>>TypeScript>>正文


TypeScript static.downgradeInjectable函數代碼示例

本文整理匯總了TypeScript中@angular/upgrade/static.downgradeInjectable函數的典型用法代碼示例。如果您正苦於以下問題:TypeScript downgradeInjectable函數的具體用法?TypeScript downgradeInjectable怎麽用?TypeScript downgradeInjectable使用的例子?那麽, 這裏精選的函數代碼示例或許可以為您提供幫助。


在下文中一共展示了downgradeInjectable函數的10個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的TypeScript代碼示例。

示例1: it

  it('should run all the tests, checking that the messages are right', (done) => {

    // TODO: ANG, once we get a pattern established, module creation should be extracted to helpers.js
    @NgModule({
      imports: [BrowserModule, UpgradeModule],
      providers: [
        DummyNg2Service
      ]
    })
    class TestModule {
      public ngDoBootstrap() {}
    }

    // TODO: ANG, once we get a pattern established, downgraded module creation should be extracted to helpers.js
    const mod: any =
      angular.module(DUMMY_NG2_SERVICE, []).factory(DUMMY_DOWNGRADE.injectionName, downgradeInjectable(DummyNg2Service));
    bootstrap(platformBrowserDynamic(), TestModule, html('<div>'), [mod.name, DUMMY_NG1_SERVICE])
      .then((upgrade) => {
        const injector: any = upgrade.$injector;
        const dummyNg2Service: DummyNg2Service = injector.get(DUMMY_DOWNGRADE.injectionName) as DummyNg2Service;
        expect(dummyNg2Service).toBeDefined();
        expect(dummyNg2Service.getMessage()).toBe('Dummy NG2 Service');

        const dummyNg1Service: DummyNg1Service = injector.get('dummyNg1Service') as DummyNg1Service;
        expect(dummyNg1Service).toBeDefined();
        expect(dummyNg1Service.getMessage()).toBe('Dummy NG1 Service');
        expect(dummyNg1Service.getInjectedMessage()).toBe('Dummy NG2 Service');
        done();
      });
  });
開發者ID:jtk54,項目名稱:deck,代碼行數:30,代碼來源:dummyNg1.service.spec.ts

示例2: it

    it('should downgrade ng2 service to ng1', async(() => {
         // Tokens used in ng2 to identify services
         const Ng2Service = new OpaqueToken('ng2-service');

         // Sample ng1 NgModule for tests
         @NgModule({
           imports: [BrowserModule, UpgradeModule],
           providers: [
             {provide: Ng2Service, useValue: 'ng2 service value'},
           ]
         })
         class Ng2Module {
           ngDoBootstrap() {}
         }

         // create the ng1 module that will import an ng2 service
         const ng1Module =
             angular.module('ng1Module', []).factory('ng2Service', downgradeInjectable(Ng2Service));

         bootstrap(platformBrowserDynamic(), Ng2Module, html('<div>'), ng1Module)
             .then((upgrade) => {
               const ng1Injector = upgrade.$injector;
               expect(ng1Injector.get('ng2Service')).toBe('ng2 service value');
             });
       }));
開發者ID:awerlang,項目名稱:angular,代碼行數:25,代碼來源:injection_spec.ts

示例3: removeEdge

  removeEdge(db, user, e){
    this.init(db, user);
    this.databases[db][user].data.edges = this.databases[db][user].data.edges.filter((edge) => {
      return edge["@rid"] !== e.edge["@rid"];
    })
  },
  removeVertex(db, user, v){
    this.init(db, user);
    this.databases[db][user].data.vertices = this.databases[db][user].data.vertices.filter((vertex) => {
      return vertex["@rid"] !== v["@rid"];
    })
  },
  data(db, user){
    this.init(db, user);
    return this.databases[db][user].data;
  },
  clear(db, user) {
    this.databases[db][user].data = {vertices: [], edges: []};
  }
});

angular.module('graph.services', []).factory(
  `GraphService`,
  downgradeInjectable(GraphService));

export  {GraphService};




開發者ID:orientechnologies,項目名稱:orientdb-studio,代碼行數:26,代碼來源:graph.service.ts

示例4: downgradeInjectable

  .component('lMdContent', MdContentComponent)
  .component('lMdToolbar', MdToolbarComponent)
  .component('lMdSidenav', MdSidenavComponent)
  .component('lMdIcon', MdIconComponent)
  .component('lMdProgressLinear', MdProgressLinearComponent)
  .component('lMdCard', MdCardComponent)

  // angular 1 app services
  .service('lMenuService', MenuService)
  .service('lLineItemService', LineItemService)
  .service('lOrderService', OrderService)
  .service('lBasketService', BasketService)
  .service('lUserService', UserService)
  .service('lToastService', ToastService)
  .service('lPriceService', PriceService)
  .factory('router', downgradeInjectable(RouterWrapper))
  .factory('configService', downgradeInjectable(ConfigService))

  // angular 1 app filters
  .filter('lDate', DateFilter)

  // angular 2 app components to be used in angular 1 app
  .directive('lApp', downgradeComponent({component: AppComponent}) as angular.IDirectiveFactory)
  .directive('lExample', downgradeComponent({component: ExampleComponent}) as angular.IDirectiveFactory)
  .directive('lFlashMessage', downgradeComponent({component: FlashMessageComponent}) as angular.IDirectiveFactory)
  .directive('lPastDaysSwitcher', downgradeComponent({
    component: PastDaysSwitcherComponent,
    inputs: ['switched'],
    outputs: ['switch']
  }) as angular.IDirectiveFactory)
  .directive('lMenuCover', downgradeComponent({
開發者ID:lunches-platform,項目名稱:fe,代碼行數:31,代碼來源:app.module.ts

示例5: transform

import {downgradeInjectable} from '@angular/upgrade/static';
import {Injectable} from "@angular/core";

declare var angular: any;

@Injectable()
export class FormatArrayPipe {

  transform(input) {
    if (input instanceof Array) {
      var output = "";
      input.forEach(function (e, idx) {
        output += (idx > 0 ? ", " : " ") + e;
      })
      return output;
    } else {
      return input;
    }
  }
}

angular.module('legacy.filters', []).factory(
  `FormatArrayPipe`,
  downgradeInjectable(FormatArrayPipe));

開發者ID:orientechnologies,項目名稱:orientdb-studio,代碼行數:24,代碼來源:formatArray.pipe.ts

示例6: constructor

import { heroDetailComponent } from './hero-detail.component';

// #docregion ngmodule, register
import { Heroes } from './heroes';
// #enddocregion register

@NgModule({
  imports: [
    BrowserModule,
    UpgradeModule
  ],
  providers: [ Heroes ]
})
export class AppModule {
  constructor(private upgrade: UpgradeModule) { }
  ngDoBootstrap() {
    this.upgrade.bootstrap(document.body, ['heroApp'], { strictDi: true });
  }
}
// #enddocregion ngmodule
// #docregion register
import { downgradeInjectable } from '@angular/upgrade/static';

angular.module('heroApp', [])
  .factory('heroes', downgradeInjectable(Heroes))
  .component('heroDetail', heroDetailComponent);
// #enddocregion register

platformBrowserDynamic().bootstrapModule(AppModule);
開發者ID:AnthonyPAlicea,項目名稱:angular,代碼行數:29,代碼來源:app.module.ts

示例7: HubConnection

        this._hubConnection = new HubConnection('/myvotehub');

        this._hubConnection.on('pollAdded',
            (...msg: any[]) => {
                if (this.pollAddedObserver) {
                    this.pollAddedObserver.next(msg[0]);
                }
            });

        this._hubConnection.start()
            .then(() => {
                console.log('MyVoteHub connection started');
            })
            .catch(err => {
                console.log('Error while establishing connection');
            });

        this.pollAddedChanged$ = new Observable((observer: any) => this.pollAddedObserver = observer).share();
    }

    public addPollNotification(): void {
        //Invoking 'AddPollAsync' method defined in SignalR hub
        this._hubConnection.invoke('AddPollAsync');
    }

}

angular.module('MyVoteApp')
    .factory('ngSignalRService', downgradeInjectable(SignalRService));
開發者ID:Magenic,項目名稱:MyVote,代碼行數:29,代碼來源:signalr.service.ts

示例8: downgradeComponent

        outputs: ['checkedChange']
    }));
    SdcUiComponentsNg1Module.directive('sdcRadioGroup', downgradeComponent({
        component: Components.RadioGroupComponent,
        inputs: ['legend', 'options', 'disabled', 'value', 'direction'],
        outputs: ['valueChange']
    }));

    // Buttons
    SdcUiComponentsNg1Module.directive('sdcButton', downgradeComponent({
        component: Components.ButtonComponent,
        inputs: ['text', 'disabled', 'type', 'size', 'preventDoubleClick', 'icon_name', 'icon_positon']
    }));

    // Modals
    SdcUiComponentsNg1Module.service('SdcModalService', downgradeInjectable(Components.ModalService));
    SdcUiComponentsNg1Module.directive('sdcModal', downgradeComponent({
        component: Components.ModalComponent,
        inputs: ['size', 'title', 'message', 'buttons', 'type'],
        outputs: ['closeAnimationComplete']
    }));
    SdcUiComponentsNg1Module.directive('sdcModalButton', downgradeComponent({
        component: Components.ModalButtonComponent,
        inputs: ['callback', 'closeModal']
    }));

    // Notifications
    SdcUiComponentsNg1Module.service('SdcNotificationService', downgradeInjectable(Components.NotificationsService));
    SdcUiComponentsNg1Module.directive('sdcNotificationContainer', downgradeComponent({
        component: Components.NotificationContainerComponent
    }));
開發者ID:onap-sdc,項目名稱:sdc-ui,代碼行數:31,代碼來源:ng1.module.ts

示例9: downgradeInjectable

SPINNAKER_DOWNGRADES.forEach((item) => {
  DOWNGRADED_MODULE_NAMES.push(item.moduleName);
  providers.push(item.moduleClass);
  angular.module(item.moduleName, []).factory(item.injectionName, downgradeInjectable(item.moduleClass));
});
開發者ID:jtk54,項目名稱:deck,代碼行數:5,代碼來源:app.module.ts

示例10: status

  status() {
    let url = API + 'etl/status';
    return this.http.get(url).toPromise().then((data) => {
      return data.json();
    });
  }

  saveConfiguration(params) {
    let url = API + 'etl/save-config';
    return this.http.post(url, params).toPromise().then((data) => {
      return data.json();
    });
  }

  initDatabase2Configs() {
    let url = API + 'etl/list-configs';
    return this.http.post(url, undefined).toPromise().then((data) => {
      return data.json();
    });
  }

}


angular.module('command.services', []).factory(
  `EtlService`,
  downgradeInjectable(EtlService));

export {EtlService};
開發者ID:orientechnologies,項目名稱:orientdb-studio,代碼行數:29,代碼來源:etl.service.ts


注:本文中的@angular/upgrade/static.downgradeInjectable函數示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。