在Angular中隐藏窗体有多种方法,以下是其中几种常见的方法:
<div *ngIf="!showForm">
<!-- 窗体内容 -->
</div>
<div [ngClass]="{'hide': !showForm}">
<!-- 窗体内容 -->
</div>
.hide {
display: none;
}
import { Component, ViewChild, ElementRef } from '@angular/core';
@Component({
selector: 'app-example',
template: `
<div #form>
<!-- 窗体内容 -->
</div>
`
})
export class ExampleComponent {
@ViewChild('form') form: ElementRef;
hideForm() {
this.form.nativeElement.style.display = 'none';
}
showForm() {
this.form.nativeElement.style.display = 'block';
}
}
以上是几种在Angular中隐藏窗体的常见方法。根据具体的需求和场景,可以选择适合的方法来隐藏窗体。
领取专属 10元无门槛券
手把手带您无忧上云