Angular 2中指令属性的默认值?

时间:2016-08-21 18:38:16

标签: angular

<drctv
    (eating)="eating()"
    [apple]="tree"
    [ice]="cone">
</drctv>

在模板中给出上面的代码,是否可以定义默认值并仅在需要时设置属性?

E.g。

<drctv     
    [ice]="chocolate">
</drctv>

,其余的指令在组件中设置为各自的默认值,但在指令中更好,例如:

@Input() apple: string = "tree";
@Output() eating = new EventEmitter();

0 个答案:

没有答案
相关问题