How to use the @angular/upgrade/static.downgradeComponent 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 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({
        component: Components.PopupMenuItemComponent,
github CSCfi / exam / app / frontend / src / enrolment / enrolment.module.ajs.ts View on Github external
import { CollaborativeExamSearchComponent } from './search/collaborativeExamSearch.component';
import { ExamSearchComponent } from './search/examSearch.component';
import { ExamSearchResultComponent } from './search/examSearchResult.component';
import { WaitingRoomComponent } from './waiting-room/waitingRoom.component';
import { WrongLocationComponent } from './wrong-location/wrongLocation.component';
import { WrongLocationService } from './wrong-location/wrongLocation.service';

require('../common');
require('../exam'); // TODO: refactor
require('../calendar/calendar.module.ajs.ts');

export default angular
    .module('app.enrolment', ['app.common', 'app.exam', 'app.calendar'])
    .service('Enrolment', downgradeInjectable(EnrolmentService))
    .service('WrongLocation', downgradeInjectable(WrongLocationService))
    .directive('activeEnrolment', downgradeComponent({ component: ActiveEnrolmentComponent }))
    .directive('enrolmentDetails', downgradeComponent({ component: EnrolmentDetailsComponent }))
    .directive('examEnrolments', downgradeComponent({ component: ExamEnrolmentsComponent }))
    .directive(
        'collaborativeExamParticipations',
        downgradeComponent({ component: CollaborativeExamParticipationsComponent }),
    )
    .directive('examFeedback', downgradeComponent({ component: ExamFeedbackComponent }))
    .directive('examParticipation', downgradeComponent({ component: ExamParticipationComponent }))
    .directive('examParticipations', downgradeComponent({ component: ExamParticipationsComponent }))
    .directive('collaborativeExamSearch', downgradeComponent({ component: CollaborativeExamSearchComponent }))
    .directive('examSearch', downgradeComponent({ component: ExamSearchComponent }))
    .directive('examSearchResult', downgradeComponent({ component: ExamSearchResultComponent }))
    .directive('waitingRoom', downgradeComponent({ component: WaitingRoomComponent }))
    .directive('wrongLocation', downgradeComponent({ component: WrongLocationComponent })).name;
github angular / angular / packages / examples / upgrade / static / ts / full / module.ts View on Github external
});
// #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; }
  ],
  // This template makes use of the downgraded `ng2-heroes` component
  // Note that because its element is compiled by AngularJS we must use kebab-case attributes
  // for inputs and outputs
  template: `
github CSCfi / exam / app / frontend / src / exam / collaborative / index.ts View on Github external
* https://joinup.ec.europa.eu/software/page/eupl/licence-eupl
 *
 * Unless required by applicable law or agreed to in writing, software distributed under the Licence is distributed
 * on an "AS IS" basis, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the Licence for the specific language governing permissions and limitations under the Licence.
 */
import { downgradeComponent, downgradeInjectable } from '@angular/upgrade/static';
import * as angular from 'angular';

import { CollaborativeExamService } from './collaborativeExam.service';
import { CollaborativeExamListingComponent } from './collaborativeExamListing.component';

export default angular
    .module('app.exam.collaborative', [])
    .service('CollaborativeExam', downgradeInjectable(CollaborativeExamService))
    .directive('collaborativeExamListing', downgradeComponent({ component: CollaborativeExamListingComponent })).name;
github thelgevold / ui-router-ngupgrade / src / angular / ng-upgrade / ng-upgrade.component.ts View on Github external
constructor(upgrade: UpgradeModule, upgradeService: NgUpgradeService) {
    if(upgradeService.bootstrapped === false) {
      angular.module('awesome').directive('survey', downgradeComponent({component: SurveyDemo}));
      
      upgrade.bootstrap(document.querySelector('#awesome'), ['awesome']);
      upgradeService.bootstrapped = true;
    }
  }  
}
github opf / openproject / frontend / app / components / work-packages / wp-breadcrumb / wp-breadcrumb.component.ts View on Github external
import {wpControllersModule} from '../../../angular-modules';
import {Component, Input} from '@angular/core';
import {downgradeComponent} from '@angular/upgrade/static';
import {WorkPackageResource} from 'core-app/modules/hal/resources/work-package-resource';

@Component({
  template: require('!!raw-loader!./wp-breadcrumb.html'),
  selector: 'wp-breadcrumb',
})
export class WorkPackageBreadcrumbComponent {
  @Input('workPackage') workPackage:WorkPackageResource;
}

wpControllersModule.directive(
  'wpBreadcrumb',
  downgradeComponent({component: WorkPackageBreadcrumbComponent })
);
github thelgevold / angular-samples / upgrade.js View on Github external
import { platformBrowser } from '@angular/platform-browser';
import { UpgradeModule } from '@angular/upgrade/static';
import { downgradeComponent, downgradeInjectable } from '@angular/upgrade/static';
import { TextEditor } from './components/text-editor/text-editor';
import { Algorithms } from './components/algorithms/algorithms';
import { SurveyDemo } from './components/survey/survey-demo';
import { AngularModuleNgFactory } from './upgrade-aot/upgrade-module.ngfactory';
import { UpgradePubSubService } from './upgrade-pub-sub.service';
import { MessageComponent } from './message.component';
angular.module('angular-legacy').directive('algorithms', downgradeComponent({ component: Algorithms }));
angular.module('angular-legacy').directive('survey', downgradeComponent({ component: SurveyDemo }));
angular.module('angular-legacy').directive('editor', downgradeComponent({ component: TextEditor }));
angular.module('angular-legacy').directive('message', downgradeComponent({ component: MessageComponent }));
angular.module('angular-legacy').service('messageService', downgradeInjectable(UpgradePubSubService));
platformBrowser().bootstrapModuleFactory(AngularModuleNgFactory).then(function (ref) {
    var adapter = ref.injector.get(UpgradeModule);
    adapter.bootstrap(document.body, ['angular-legacy']);
});
github opf / openproject / frontend / src / app / components / work-packages / wp-breadcrumb / wp-breadcrumb.component.ts View on Github external
import {wpControllersModule} from '../../../angular-modules';
import {Component, Input} from '@angular/core';
import {downgradeComponent} from '@angular/upgrade/static';
import {WorkPackageResource} from 'core-app/modules/hal/resources/work-package-resource';

@Component({
  templateUrl: './wp-breadcrumb.html',
  selector: 'wp-breadcrumb',
})
export class WorkPackageBreadcrumbComponent {
  @Input('workPackage') workPackage:WorkPackageResource;
}

wpControllersModule.directive(
  'wpBreadcrumb',
  downgradeComponent({component: WorkPackageBreadcrumbComponent })
);
github opf / openproject / frontend / app / components / wp-workflow-buttons / wp-workflow-buttons.component.ts View on Github external
@Component({
  selector: 'wp-workflow-buttons',
  template: require('!!raw-loader!./wp-workflow-buttons.component.html')
})
export class WpWorkflowButtonsComponent {

  @Input() workPackage:WorkPackageResource;

  public get actions() {
    return this.workPackage.customActions;
  }
}

opUiComponentsModule.directive(
  'wpWorkflowButtons',
  downgradeComponent({component:WpWorkflowButtonsComponent})
);
github thelgevold / angular-samples / src / apps / ng-upgrade-app / upgrade.ts View on Github external
import {Algorithms} from '../shared-components/algorithms/algorithms';
import {SurveyDemo} from '../shared-components/survey/survey-demo';

import {AngularModuleNgFactory} from './upgrade-module.ngfactory';

declare var angular: any;

angular
  .module('angular-legacy')
  .directive('algorithms', downgradeComponent({component: Algorithms}));
angular
  .module('angular-legacy')
  .directive('survey', downgradeComponent({component: SurveyDemo}));
angular
  .module('angular-legacy')
  .directive('editor', downgradeComponent({component: TextEditor}));

platformBrowser()
  .bootstrapModuleFactory(AngularModuleNgFactory)
  .then(ref => {
    const adapter = ref.injector.get(UpgradeModule) as UpgradeModule;
    adapter.bootstrap(document.body, ['angular-legacy']);
  });