在我的角度应用程序中,我在页面中创建了仪表板页面,我为开始或停止创建了一个按钮(即切换),但它不能正常工作。
.component.ts
toggleCollapse(jammer) {
this.jammer.isCollapsed ? 'START' : 'STOP'
this.jammer.isCollapsed ? 'START' : 'STOP'
}.component.html
<button
type="button"
class="btn btn-warning"
(click)="toggleCollapse()">START</button>但是它不能正常工作,有人能在这方面帮我吗?
发布于 2020-10-12 12:38:52
.component.ts
public isCollapsed = false;
toggleCollapse() {
this.isCollapsed = !this.isCollapsed
}.component.html
<button
type="button"
[ngClass]="isCollapsed ? 'btn btn-warning' : 'btn btn-success'"
(click)="toggleCollapse()">
<span *ngIf="isCollapsed"> Stop <span>
<span *ngIf="!isCollapsed"> Start <span>
</button>注意:如果需要,可以更改布尔值。
发布于 2020-10-12 12:33:26
我想你想要按钮的标签是开始还是停止?
isCollapsed: boolean = true;
toggleCollapse() {
this.isCollapsed = !this.isCollapsed;
}<button
type="button"
class="btn btn-warning"
(click)="toggleCollapse()">{{isCollapsed? 'START' : 'STOP'}}</button>https://stackoverflow.com/questions/64317835
复制相似问题