How to use the @angular/upgrade/static.downgradeInjectable function in @angular/upgrade

To help you get started, we’ve selected a few @angular/upgrade examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github oppia / oppia / core / templates / dev / head / services / construct-translation-ids.service.ts View on Github external
@Injectable({
  providedIn: 'root'
})
export class ConstructTranslationIdsService {
  // Construct a translation id for library from name and a prefix.
  // Ex: 'categories', 'art' -> 'I18N_LIBRARY_CATEGORIES_ART'
  getLibraryId(prefix: string, name: string): string {
    return (
      'I18N_LIBRARY_' + prefix.toUpperCase() + '_' +
        name.toUpperCase().split(' ').join('_'));
  }
}

angular.module('oppia').factory(
  'ConstructTranslationIdsService',
  downgradeInjectable(ConstructTranslationIdsService));
github oppia / oppia / core / templates / dev / head / domain / statistics / LearnerActionObjectFactory.ts View on Github external
*/
  // TODO(#7176): Replace 'any' with the exact type. This has been kept as
  // 'any' because 'learnerActionBackendDict' is a dict with underscore_cased
  // keys which give tslint errors against underscore_casing in favor of
  // camelCasing.
  createFromBackendDict(learnerActionBackendDict: any): LearnerAction {
    return new LearnerAction(
      learnerActionBackendDict.action_type,
      learnerActionBackendDict.action_customization_args,
      learnerActionBackendDict.schema_version);
  }
}

angular.module('oppia').factory(
  'LearnerActionObjectFactory',
  downgradeInjectable(LearnerActionObjectFactory));
github scenarioo / scenarioo / scenarioo-client / app / services / localStorage.service.ts View on Github external
* @param key the key to make scenarioo context aware
     * @returns {string} key with scenarioo context path from location url inside.
     */
    getScenariooContextPathAwareKey(key: string): string {

        // TODO: Workaround until the full migration, when the Angular router is available
        // this.currentBrowserLocation = this.location.prepareExternalUrl(this.location.path());
        this.currentBrowserLocation = (this.platformLocation as any).location.href;

        return '/' + this.urlContextExtractorService.getContextPathFromUrl(this.currentBrowserLocation) + '/' + key;
    }

}

angular.module('scenarioo.services')
    .factory('LocalStorageService', downgradeInjectable(LocalStorageService));
github onap-sdc / sdc-ui / src / angular / ng1.module.ts View on Github external
}));

    // 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
    }));
    SdcUiComponentsNg1Module.directive('sdcNotification', downgradeComponent({
        component: Components.NotificationComponent,
        inputs: ['notificationSetting'],
        outputs: ['destroyComponent']
    }));

    // Popup Menu
    SdcUiComponentsNg1Module.directive('popupMenuList', downgradeComponent({
        component: Components.PopupMenuListComponent,
        inputs: ['open', 'position', 'className', 'relative'],
        outputs: ['openChange', 'positionChange']
    }));
    SdcUiComponentsNg1Module.directive('popupMenuItem', downgradeComponent({
github angular / angular / packages / examples / upgrade / static / ts / full / module.ts View on Github external
transclude: true,
  template: `<div class="title"></div>
             <h2>{{ $ctrl.hero.name }}</h2>
             <p>{{ $ctrl.hero.description }}</p>
             <button>Remove</button>`
});
// #enddocregion

// #docregion ng1-text-formatter-service
// This AngularJS service will be "upgraded" to be used in Angular
ng1AppModule.service('textFormatter', [TextFormatter]);
// #enddocregion

// #docregion downgrade-ng2-heroes-service
// Register an AngularJS service, whose value is the "downgraded" Angular injectable.
ng1AppModule.factory('heroesService', downgradeInjectable(HeroesService) as any);
// #enddocregion

// #docregion ng2-heroes-wrapper
// This directive will act as the interface to the "downgraded" Angular component
ng1AppModule.directive('ng2Heroes', downgradeComponent({component: Ng2HeroesComponent}));
// #enddocregion

// #docregion example-app
// This is our top level application component
ng1AppModule.component('exampleApp', {
  // We inject the "downgraded" HeroesService into this AngularJS component
  // (We don't need the `HeroesService` type for AngularJS DI - it just helps with TypeScript
  // compilation)
  controller: [
    'heroesService', function(heroesService: HeroesService) { this.heroesService = heroesService; }
  ],
github onap / sdc / catalog-ui / src / app / modules / service-module.ts View on Github external
//Utils
serviceModule.service('ArtifactsUtils', ArtifactsUtils);
serviceModule.service('FileUtils', FileUtils);
serviceModule.service('ValidationUtils', ValidationUtils);

serviceModule.service('AngularJSBridge',AngularJSBridge);
serviceModule.service('LoaderService', LoaderService);

serviceModule.factory('Sdc.Services.CategoryResourceService', CategoryResourceService.getResource);

// Angular2 upgraded services - This is in order to use the service in angular1 till we finish remove all angular1 code
serviceModule.factory('ComponentServiceNg2', downgradeInjectable(ComponentServiceNg2));
serviceModule.factory('ComponentServiceFactoryNg2', downgradeInjectable(ComponentServiceFactoryNg2));
serviceModule.factory('ServiceServiceNg2', downgradeInjectable(ServiceServiceNg2));
serviceModule.factory('ModalServiceNg2', downgradeInjectable(ModalService));
serviceModule.factory('ModalServiceSdcUI', downgradeInjectable(SdcUiComponents.ModalService));
serviceModule.factory('ConnectionWizardServiceNg2', downgradeInjectable(ConnectionWizardService));
serviceModule.factory('ComponentInstanceServiceNg2', downgradeInjectable(ComponentInstanceServiceNg2));
serviceModule.factory('UserServiceNg2', downgradeInjectable(UserServiceNg2));
serviceModule.factory('PoliciesServiceNg2', downgradeInjectable(PoliciesServiceNg2));
serviceModule.factory('GroupsServiceNg2', downgradeInjectable(GroupsServiceNg2));
serviceModule.factory('PluginsService', downgradeInjectable(PluginsService));
serviceModule.factory('EventBusService', downgradeInjectable(EventBusService));
serviceModule.factory('DynamicComponentService', downgradeInjectable(DynamicComponentService));
serviceModule.factory('ArchiveServiceNg2', downgradeInjectable(ArchiveServiceNg2));
serviceModule.factory('GabServiceNg2', downgradeInjectable(GabServiceNg2));
serviceModule.factory('AutomatedUpgradeService', downgradeInjectable(AutomatedUpgradeService));
serviceModule.factory('ToscaTypesServiceNg2', downgradeInjectable(ToscaTypesServiceNg2));
github oppia / oppia / core / templates / dev / head / domain / collection / CollectionRightsObjectFactory.ts View on Github external
create(collectionRightsBackendObject: any): CollectionRights {
    return new CollectionRights(cloneDeep(collectionRightsBackendObject));
  }

  // Create a new, empty collection rights object. This is not guaranteed to
  // pass validation tests.
  createEmptyCollectionRights(): CollectionRights {
    return new CollectionRights({
      owner_names: []
    });
  }
}

angular.module('oppia').factory(
  'CollectionRightsObjectFactory',
  downgradeInjectable(CollectionRightsObjectFactory));
github oppia / oppia / core / templates / dev / head / domain / utilities / AudioLanguageObjectFactory.ts View on Github external
})
export class AudioLanguageObjectFactory {
  // TODO(#7176): Replace 'any' with the exact type. This has been kept as
  // 'any' because 'audioLanguageDict' is a dict with underscore_cased
  // keys which give tslint errors against underscore_casing in favor of
  // camelCasing.
  createFromDict(audioLanguageDict: any): AudioLanguage {
    return new AudioLanguage(
      audioLanguageDict.id,
      audioLanguageDict.description,
      audioLanguageDict.related_languages);
  }
}
angular.module('oppia').factory(
  'AudioLanguageObjectFactory',
  downgradeInjectable(AudioLanguageObjectFactory));
github oppia / oppia / core / templates / dev / head / domain / skill / MisconceptionObjectFactory.ts View on Github external
misconceptionBackendDict.id,
      misconceptionBackendDict.name,
      misconceptionBackendDict.notes,
      misconceptionBackendDict.feedback,
      misconceptionBackendDict.must_be_addressed);
  }
  create(
      id: string, name: string, notes: string,
      feedback: string, mustBeAddressed: boolean): Misconception {
    return new Misconception(id, name, notes, feedback, mustBeAddressed);
  }
}

angular.module('oppia').factory(
  'MisconceptionObjectFactory',
  downgradeInjectable(MisconceptionObjectFactory));
github Teradata / kylo / ui / ui-app / src / main / resources / static / js / feed-mgr / feed-mgr.module-require.ts View on Github external
angular.module(moduleName).service("UiComponentsService", UiComponentsService);

angular.module(moduleName).service('FeedPropertyService', DefaultFeedPropertyService);

angular.module(moduleName).service('FeedInputProcessorPropertiesTemplateService',FeedInputProcessorPropertiesTemplateService);

angular.module(moduleName).service('FeedDetailsProcessorRenderingHelper', FeedDetailsProcessorRenderingHelper);

angular.module(moduleName).service('EditFeedNifiPropertiesService', EditFeedNifiPropertiesService); 

angular.module(moduleName).service('RegisterTemplateService', RegisterTemplateServiceFactory);

angular.module(moduleName).service('RegisterTemplatePropertyService', RegisterTemplatePropertyService);

angular.module(moduleName).factory('RestUrlService', downgradeInjectable(RestUrlService));

angular.module(moduleName).factory('SlaService', downgradeInjectable(SlaService));

angular.module(moduleName).factory('CategoriesService', downgradeInjectable(SlaService));

angular.module(moduleName).factory('DatasourcesService', downgradeInjectable(DatasourcesService));

angular.module(moduleName).factory('PolicyInputFormService', downgradeInjectable(PolicyInputFormService));

angular.module(moduleName).service('FeedCreationErrorService', FeedCreationErrorService);

angular.module(moduleName).service('DBCPTableSchemaService', DBCPTableSchemaService);

angular.module(moduleName).service("DatasourcesService",DatasourcesService);