I'm trying to use UpgradeComponent in order to use Angular 1 library (ui-grid) in my Angular 4 application.
My steps:
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(); } }
Add it to my module
declarations: [UiGridDirective],
Tried import it in my index.html
<script src="https://cdn.rawgit.com/angular-ui/bower-ui-grid/master/ui-grid.min.js"/>
Got this erors:
Before step 3:
ERROR Error: Uncaught (in promise): Error: StaticInjectorError[$injector]:
StaticInjectorError[$injector]:
NullInjectorError: No provider for $injector!
After step 3:
Any idea how I can use this AngularJS library in my Angular 4 application?