angular - 从 [NgStyle] 传递字符串
问题描述
您好,当我在同一页面上按下按钮时,我想显示一个文本区域。
html
<button ion-button [NgStyle]="type=='text'">
<ion-item *ngIf="type=='text'">
<ion-textarea>....</ion-texarea>
</ion-item>
.ts
type:string='';
component(){}
我究竟做错了什么?
解决方案
您可以执行以下操作:
在 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;
}
推荐阅读
- javascript - javascript - 点击事件目标排除孩子
- twilio - 来自 Safari iPhone 的远程视频显示黑屏
- r - 未找到 rshiny 中的范围输入
- ruby - 如何在 Ruby 中为旅行费用计划存储多个用户响应
- php - 获取表记录,除了在另一个表中具有外键值的记录
- angular - 非嵌套组件的数据绑定
- pyqt5 - 如何过滤 QListWidget 中的项目
- linker - 链接 SFML 文件时 dev c++ 中的链接器错误
- postgresql - Liquibase - 将数据库从 PostgreSQL 迁移到 Microsoft SQL Server
- php - phpmailer - 是否可以使用 html 文件的指定路径调用消息正文?