2016-06-07 5 views
1

에 입력 설정 타입 I 다음 지시문이 있습니다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> 

내가 부울 형식을 취할 숨기기를 강제 수 어쨌든 있나요?

답변

3

원하는대로 할 수 있습니다.

각도가 문자열로 대신 표현으로 값을 해석 []없이
<p myDirnumber=1 [hide]="false"> 

.

+2

감사합니다. 나는 그 사실을 잊어 버렸다. – Scipion