I am using Angular 2 version "2.1.0" and writing below "SpinnerService".
This below code is from Angular RC 1 and not supported in version "2.1.0",
this is plnkr code I m referring,
http://plnkr.co/edit/Y2ocRpbi2ORjbULrguDg?p=info
import { Injectable, DynamicComponentLoader, ApplicationRef, ElementRef, ComponentRef } from '@angular/core';
import { SpinnerComponent } from '../components/blockui/blockui.component';
@Injectable()
export class SpinnerService {
spinnerComp: ComponentRef;
constructor(private componentLoader: DynamicComponentLoader, private appRef: ApplicationRef) { }
public start() {
let elementRef: ElementRef = this.appRef['_rootComponents'][0].location;
return this.startInside(elementRef, null);
}
public startInside(elementRef: ElementRef, anchorName: string) {
let spinnerRef = (!anchorName) ?
this.componentLoader.loadNextToLocation(SpinnerComponent, elementRef) :
this.componentLoader.loadIntoLocation(SpinnerComponent, elementRef, anchorName);
spinnerRef.then((compRef: ComponentRef) => {
this.spinnerComp = compRef;
});
}
public stop() {
if (this.spinnerComp) {
this.spinnerComp.dispose();
}
}
}
I am getting below error,
- error TS2305: Module '"C:/bugFix/WebPackPOC/src/WebPackApp/node_modules/@angular/core/index"' has no exported member 'DynamicComponentLoader'.
- error TS2314: Generic type 'ComponentRef' requires 1 type argument(s).
- error TS7017: Index signature of object type implicitly has an 'any' type.
- error TS2314: Generic type 'ComponentRef' requires 1 type argument(s).
Please suggest what change need to make to work this with version 2.1.0? Thanks!