1
设置输入类型,我有以下指令:Angular2:在指令
@Directive({
selector: "[myDir]"
})
export class MyDir implements OnInit {
private el:HTMLElement
@Input() hide: boolean
constructor(el: ElementRef) {
this.el = el.nativeElement
}
ngInit() {
console.log(typeof this.hide) // Writes string in the console
}
}
模板:
<p myDirnumber=1 hide=false></p>
反正是有,我可以迫使隐藏采取boolean类型?
现货,谢谢!我没有忘记这一点。 – Scipion