angular - Angular - 点击后显示额外的 div
解决方案
这个 stackblitz 示例可以满足您的需要。
https://stackblitz.com/edit/angular-cnbzuv?embed=1&file=src/app/app.component.ts
HTML
<button style="float: right;" (click)="clicked()">click me</button>
<div *ngIf="buttonClicked" style="clear:both; with:100%; text-align: center; padding:10vh; border-style: solid; border-color: yellow;">Div content here</div>
零件
import { Component } from '@angular/core';
@Component({
selector: 'my-app',
templateUrl: './app.component.html',
styleUrls: [ './app.component.css' ]
})
export class AppComponent {
buttonClicked = false;
clicked(){
this.buttonClicked = !this.buttonClicked;
}
}
推荐阅读
- java - 将数据库连接到 TableView 时出现“java.lang.reflect.InvocationTargetException”
- javascript - Mongoose 我们如何更新嵌套对象
- python - 如何使用 Google Colab 在 python 中获取工作文件名
- c# - Blazor 服务器应用程序模板不适用于 Visual Studio 2019 v 16.11.3
- pandoc - 在较新的 pandoc 中从 yml 文件和模板创建文档的问题
- c# - 为什么我的 Blazor 输入字段在我有 for 循环确保不超出范围时显示索引超出范围?
- python - Django 模板 URL 无法识别全局值
- python - 使用对谷歌表单的请求
- typescript - 用 Jest 测试投掷
- r - 无法在 R 的列表中附加向量