2

I'm trying to use UpgradeComponent in order to use Angular 1 library (ui-grid) in my Angular 4 application.

My steps:

  1. Create a new directive:

    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. Add it to my module

     declarations: [UiGridDirective],
    
  3. Tried import it in my index.html

    <script src="https://cdn.rawgit.com/angular-ui/bower-ui-grid/master/ui-grid.min.js"/>
    
  4. Got this erors:

Before step 3:

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

After step 3:

enter image description here

Any idea how I can use this AngularJS library in my Angular 4 application?

TheUnreal
  • 23,434
  • 46
  • 157
  • 277

0 Answers0