簡體   English   中英

在 index.html 的組件調用中傳遞布爾值

[英]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.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM