0
角度2のバージョンRC5のバージョンの前にカスタムデコレータを使用していましたが、エラーは発生しません。これを解決する考えはありますか?は角度2のdecorator/annonationを継承しています
チュートリアル(NgModule前 )Angular2のRC5のバージョンの前に罰金働いていたコードの上https://medium.com/@ttemplier/angular2-decorators-and-class-inheritance-905921dbd1b7#.yqki96a5y でエラー・スタックだった
@CustomComponent({
selector: 'sub'
})
export class SubComponent extends AbstractComponent {
}
として上記使用
export function CustomComponent(annotation: any) {
return function (target: Function) {
var parentTarget = Object.getPrototypeOf(target.prototype).constructor;
var parentAnnotations = Reflect.getMetadata('annotations', parentTarget);
var parentAnnotation = parentAnnotations[0];
Object.keys(parentAnnotation).forEach(key => {
if (isPresent(parentAnnotation[key])) {
if (!isPresent(annotation[key])) {
annotation[key] = parentAnnotation[key];
}
}
});
var metadata = new ComponentMetadata(annotation);
Reflect.defineMetadata('annotations', [ metadata ], target);
};
};
- >
Error: (SystemJS) parentAnnotations is undefined
CustomComponent/<@http://localhost:3000/app/customCompo.js:8:13
[email protected]://localhost:3000/node_modules/reflect-metadata/Reflect.js:531:29
[email protected]://localhost:3000/node_modules/reflect-metadata/Reflect.js:115:20
__decorate<@http://localhost:3000/app/app.component.js:4:84
AppComponent<@http://localhost:3000/app/app.component.js:16:20
@http://localhost:3000/app/app.component.js:12:21
@http://localhost:3000/app/app.component.js:1:31
@http://localhost:3000/app/app.component.js:1:2
@http://localhost:3000/app/app.module.js:13:23
@http://localhost:3000/app/app.module.js:1:31
@http://localhost:3000/app/app.module.js:1:2
@http://localhost:3000/app/main.js:3:20
@http://localhost:3000/app/main.js:1:31
@http://localhost:3000/app/main.js:1:2
[email protected]://localhost:3000/node_modules/zone.js/dist/zone.js:229:17
[email protected]://localhost:3000/node_modules/zone.js/dist/zone.js:113:24
scheduleResolveOrReject/<@http://localhost:3000/node_modules/zone.js/dist/zone.js:509:52
[email protected]://localhost:3000/node_modules/zone.js/dist/zone.js:262:21
[email protected]://localhost:3000/node_modules/zone.js/dist/zone.js:151:28
[email protected]://localhost:3000/node_modules/zone.js/dist/zone.js:405:25
ZoneTask/[email protected]://localhost:3000/node_modules/zone.js/dist/zone.js:336:25
Evaluating http://localhost:3000/app/app.component.js
Evaluating http://localhost:3000/app/app.module.js
Evaluating http://localhost:3000/app/main.js
Error loading http://localhost:3000/app/main.js
Stack trace:
(SystemJS) parentAnnotations is undefined
CustomComponent/<@http://localhost:3000/app/customCompo.js:8:13
[email protected]://localhost:3000/node_modules/reflect-metadata/Reflect.js:531:29
[email protected]://localhost:3000/node_modules/reflect-metadata/Reflect.js:115:20
__decorate<@http://localhost:3000/app/app.component.js:4:84
AppComponent<@http://localhost:3000/app/app.component.js:16:20
@http://localhost:3000/app/app.component.js:12:21
@http://localhost:3000/app/app.component.js:1:31
@http://localhost:3000/app/app.component.js:1:2
@http://localhost:3000/app/app.module.js:13:23
@http://localhost:3000/app/app.module.js:1:31
@http://localhost:3000/app/app.module.js:1:2
@http://localhost:3000/app/main.js:3:20
@http://localhost:3000/app/main.js:1:31
@http://localhost:3000/app/main.js:1:2
[email protected]://localhost:3000/node_modules/zone.js/dist/zone.js:229:17
[email protected]://localhost:3000/node_modules/zone.js/dist/zone.js:113:24
scheduleResolveOrReject/<@http://localhost:3000/node_modules/zone.js/dist/zone.js:509:52
[email protected]://localhost:3000/node_modules/zone.js/dist/zone.js:262:21
[email protected]://localhost:3000/node_modules/zone.js/dist/zone.js:151:28
[email protected]://localhost:3000/node_modules/zone.js/dist/zone.js:405:25
ZoneTask/[email protected]://localhost:3000/node_modules/zone.js/dist/zone.js:336:25
Evaluating http://localhost:3000/app/app.component.js
Evaluating http://localhost:3000/app/app.module.js
Evaluating http://localhost:3000/app/main.js
Error loading http://localhost:3000/app/main.js
昨日、コンポーネントの継承をサポートする角度2.3.0がリリースされました。 –
私は角度2.3.0で試したが運がない@トニー – anshuVersatile