0
親コンポーネントからのイベントに基づいて子コンポーネントを動的にロードしようとしています。 ImportステートメントとViewChildステートメントでコンパイルエラーが発生します。以下は、次のように1ComponentResolverとViewContainerRefをインポートできません
import { Component, ComponentResolver, ViewContainerRef, ViewChild, } from 'angular2/core';
Error: Module "...node_modules/angular2/core" has no exported member ComponentResolver
エラー#2
@ViewChild("childContainer", { read: ViewContainerRef }) childContainer: ViewContainerRef;
Error: Supplied parameters do not match any signature of call target
エラー#3
this._cr.resolveComponent(ExtractorDetails).then(cmpFactory => {
let cmpRef = this.childContainer.createComponent(cmpFactory);
cmpRef.instance.QueueID = this.queueID;
});
Error: Property createComponent does not exist on type 'ViewContainerRef'
エラー番号です:
{
"name": "ASP.NET",
"version": "0.0.0",
"dependencies": {
"angular/http": "2.0.0-rc.1",
"angular2": "2.0.0-beta.17",
"bootstrap": "^3.3.5",
"es6-promise": "^3.0.2",
"es6-shim": "^0.33.3",
"jquery": "^2.2.4",
"reflect-metadata": "0.1.2",
"rxjs": "5.0.0-beta.2",
"systemjs": "0.19.22",
"zone.js": "0.5.15"
},
"devDependencies": {
"gulp": "3.8.11",
"gulp-concat": "2.5.2",
"gulp-cssmin": "0.1.7",
"gulp-uglify": "1.2.0",
"rimraf": "2.2.8"
}
}
私の親コンポーネントは以下のようになります 'Component2、ComponentResolver、ViewContainerRef、ViewChild、'を 'angular2/core'からインポートします。 {ExtractorDetails}を './ExtractorDetails'からインポートします。 ..
@Component({
selector: 'kendo-grid',
templateUrl: './HTML/Admin/KendoGrid.html',
providers: [Configuration, Constants],
directives: [Grid]
})
export class ExtractorGrid {
options: any;
rowObject: any;
extractorDetails: any;
public component: any;
queueID: number;
@ViewChild("childContainer", { read: ViewContainerRef }) childContainer: ViewContainerRef;
constructor(private configSetttings: Configuration, private constants: Constants, private viewContainer: ViewContainerRef, private _cr: ComponentResolver) {
this.setUpGridOptions();
}
onChange(event) {
this.rowObject = event.target;
this._cr.resolveComponent(ExtractorDetails).then(cmpFactory => {
let cmpRef = this.childContainer.createComponent(cmpFactory);
cmpRef.instance.QueueID = this.queueID;
});
}
....
}
誰もが私はComponentResolverとViewContainerRefを使用する必要がある場合は参照する必要がバージョンをangular2た私を指すことができますか?
リリース候補3または4に基づいて、新しいangular2バージョンを使用することをお勧めします。rc4がリリースされました。https://github.com/angular/angular/blob/master/CHANGELOG.md (多くのものはベータステージとはかなり異なる) – Gabi
RC3で更新された "dependencies":{"angular/http": "2.0.0-rc.1"、 "angular2": "2.0.0-rc.3" 、...}でも同じエラーが発生します。何か案は ? – Krishnan
インポートを 'angular2/xxx'から' @ angular/xxx'に変更しましたか? –