![](/img/trans.png)
[英]How to pass a value from index.html page to component.ts file in angular 4
[英]Pass Boolean value in a component call from index.html
我創建了一個組件並嘗試將其中的布爾值作為@input 傳遞,這將幫助我顯示/隱藏一個 div。 但它給了我不確定的。 誰能指出這有什么問題?
索引.html
<abc-comp x="1" y="64" [showviewmore]="true"></abc-comp>
abc-comp.ts
@Input() x = '';
@Input() y = '';
@Input() showviewmore : boolean;
abc-comp.html
<div class="col-xs-4" *ngIf="showviewmore">
//Some Content and tags
</div>
試試下面的修改代碼
<abc-comp x="1" y="64" [showviewmore]="true"></abc-comp>
abc-comp.tstry
@Input() x = '';
@Input() y = '';
@Input() showviewmore : boolean =false;
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.