Parent annotation in Angular2 alpha.31


trying to add Parent annotation in Angular2 alpha31.

I use this import statement:

import {Parent} from 'angular2/annotations';

I have also added the following to angular2.d.ts:

declare module "angular2/annotations" {
    function Parent(): (target: any) => any;
    function Ancestor(): (target: any) => any;

My ts file looks like this:

/// <reference path='../../../../../typings/angular2/angular2.d.ts' />

import {Component, View} from 'angular2/angular2';
import {Parent} from 'angular2/annotations';
import {Messenger} from 'components/messenger/messenger';

    selector : 'compose',
    hostInjector : [Messenger]

    templateUrl: 'components/compose/compose.html'

export class Compose {

    title : string;
    message : string;
    messenger : Messenger;

    constructor(@Parent messenger:Messenger){
        this.messenger = messenger;

But I keep getting:

Uncaught TypeError: decorator is not a function

What am I missing? :) Thanks!


I believe the way to do this in alpha-37 is @Host.

constructor(@Host() tabs:Tabs)

Instead of @Parent, this has at least proved successful to me.

By : Skeen

I found the problem:

constructor(@Ancestor @Inject(forwardRef(() =

This video can help you solving your question :)
By: admin