首页 > 解决方案 > 从 [NgStyle] 传递字符串

问题描述

您好,当我在同一页面上按下按钮时,我想显示一个文本区域。

html

<button ion-button [NgStyle]="type=='text'">

   <ion-item *ngIf="type=='text'">
      <ion-textarea>....</ion-texarea>
   </ion-item>

.ts

type:string='';
 component(){}

我究竟做错了什么?

标签: angularionic-framework

解决方案


您可以执行以下操作:

在 HTML 中:

<ion-button color="primary" (click)="showHidetextArea()"></ion-button

   <ion-item *ngIf="show">
      <ion-textarea></ion-texarea>
   </ion-item>

在.ts里面

show: boolean = false; // declear variable

showHidetextArea(){
      this.show = !this.show;
}

推荐阅读