Angular 2 --alpha 37如何在构造函数中获取属性?

时间:2015-09-18 04:55:14

标签: angular typescript

这是我的组件,其属性是

类型
   @Component({
    selector: 'canvasContainer',
    properties: ['type']
    })
    @View({
    templateUrl: "components/canvas/canvas.html",
    directives: [Bar, CORE_DIRECTIVES],
    styleUrls: ['app.css']
    })
   export class Canvas 
    {
    constructor() {    }
    }

这是我的html页面:

<bar type="pie"></bar>

我想在我的构造函数中获取类型派,如下所示:

@Component({
        selector: 'canvasContainer',
        properties: ['type']
        })
        @View({
        templateUrl: "components/canvas/canvas.html",
        directives: [Bar, CORE_DIRECTIVES],
        styleUrls: ['app.css']
        })
       export class Canvas 
        {
        constructor() { alert(type);   }//this alert is not working
        }

0 个答案:

没有答案