【发布时间】:2020-06-17 11:18:33
【问题描述】:
我正在尝试根据条件应用 css 类。这是我的代码,但它似乎没有正确应用该类。
基本上如果selectedEmployee.isHrEmailAddress 为真,那么我想用.section-postal 覆盖section
HTML
<section [ngClass]="{'.section-postal': selectedEmployee.isHrEmailAddress}">
<div class="page-container">
<div id="wrapper">
<form *ngIf="contactDetailsForm" [formGroup]="contactDetailsForm">
<div class="text-left">
<div class="flex flex-row sm:flex-col md:flex-row-reverse lg:flex-col-reverse xl:flex-row">
<div class="check-container text-left" style="width: 450px;">
<div class="flex flex-row sm:flex-col md:flex-row-reverse lg:flex-col-reverse xl:flex-row">
<div class="line">
<p-checkbox name="isHrEmailAddress" formControlName="isHrEmailAddress"
[(ngModel)]="selectedEmployee.isHrEmailAddress" binary="true"
(onChange)="toggle('emailCheckId')">
</p-checkbox>
<span class="ml-2 pt-4" style="font-size: 15px;">I am using my email address on the
member's behalf</span>
</div>
</div>
</div>
</div>
<div class="note" *ngIf="selectedEmployee.isHrEmailAddress">
<span>Please note: You will need to confirm the employee's postal address, so that they can be
contacted in future.</span>
</div>
</div>
</form>
</div>
</div>
</section>
css
section {
height: 500px;
}
.section-postal {
height: 650px;
}
【问题讨论】: