我正在使用Angular 2版本" 2.1.0"并写在下面" SpinnerService"。
以下代码来自Angular RC 1,不支持版本" 2.1.0",
这是我所指的plnkr代码,
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();
}
}
}
我收到以下错误,
请建议使用版本2.1.0进行此更改需要进行哪些更改?谢谢!