【发布时间】:2018-10-21 00:39:21
【问题描述】:
【问题讨论】:
标签: angular css typescript
【问题讨论】:
标签: angular css typescript
这个 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;
}
}
【讨论】: