1

ParentAncestor注釈を TypeScriptの型付けに追加しようとしていたので、次のようにしました。

declare module "angular2/src/core/annotations_impl/visibility"{
   function Parent():(target: any) => any;
   function Ancestor():(target: any) => any;
}

いずれかの注釈スローを使用する"TypeError: decorator is not a function".

アルファ22を使用しています。

なぜこのエラーが発生するのですか?

以下にサンプルを示します。

/// <reference path="typings/angular2/angular2.d.ts" />
import {Component,View,bootstrap} from "angular2/angular2"
import {Ancestor,Parent} from "angular2/src/core/annotations_impl/visibility"

@Component({
    selector:"c"
})
@View({
    template:`<p>{{app.message}}</p>`
})
class C{
    app:App;
    constructor(@Ancestor() app:App){
        this.app = app;
    }
}

@Component({
    selector:"app"
})
@View({
    template:`<c></c>`,
    directives:[C]
})
class App{
    message = "test";
}
bootstrap(App);

HTML:

<html>
  <head>
    <title>Angular 2 Quickstart</title>
    <script src="https://github.jspm.io/jmcriffey/bower-traceur-runtime@0.0.89/traceur-runtime.js"></script>
    <script src="https://jspm.io/system@0.16.7.js"></script>
    <script src="https://code.angularjs.org/2.0.0-alpha.22/angular2.dev.js"></script>
  <body>
    <!-- The app component created in app.ts -->
    <app></app>
    <script>
      System.import('app');
    </script>
  </body>
</html>
4

1 に答える 1