Использование Angular UpgradeComponent

Я пытаюсь использовать UpgradeComponent для использования библиотеки Angular 1 ( ui-grid) в моем приложении Angular 4.

Мои шаги:

  1. Создайте новую директиву:

    import {
    Directive, ElementRef, Injector, Input, OnInit, SimpleChanges, OnChanges, 
    DoCheck,
    
    
    OnDestroy, Output, EventEmitter, Inject
    } from '@angular/core';
    import { UpgradeComponent } from '@angular/upgrade/static';
    
    @Directive({selector: 'ui-grid'})
    export class UiGridDirective extends UpgradeComponent implements OnInit,                 OnChanges, DoCheck,
      OnDestroy {
    
    @Input() data: {};
    @Output() onUpdate: EventEmitter<{}>;
    
    constructor(@Inject(ElementRef) elementRef: ElementRef, @Inject(Injector)                 
     injector: Injector) {
        super('ui-grid', elementRef, injector);
      }
    
      ngOnInit() { super.ngOnInit(); }
    
      ngOnChanges(changes: SimpleChanges) { super.ngOnChanges(changes); }
      ngDoCheck() { super.ngDoCheck(); }
     ngOnDestroy() { super.ngOnDestroy(); }
    }
    
  2. Добавить его в мой модуль

     declarations: [UiGridDirective],
    
  3. Пробовал импортировать его в мой index.html

    <script src="https://cdn.rawgit.com/angular-ui/bower-ui-grid/master/ui-grid.min.js"/>
    
  4. Есть ошибки:

До шага 3:

ERROR Error: Uncaught (in promise): Error: StaticInjectorError[$injector]: 
  StaticInjectorError[$injector]: 
    NullInjectorError: No provider for $injector!

После шага 3:

введите описание изображения здесь

Любая идея, как я могу использовать эту библиотеку AngularJS в моем приложении Angular 4?

0 ответов

Другие вопросы по тегам