Skip to content

Commit 4192249

Browse files
committed
change ngIf
1 parent df1bc2d commit 4192249

File tree

1 file changed

+19
-12
lines changed

1 file changed

+19
-12
lines changed

projects/demo/src/app/app.component.html

Lines changed: 19 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -11,12 +11,15 @@ <h2>Custom style</h2>
1111
<ngx-input-counter class="custom" [(ngModel)]="custom" [max]="5" [min]="0">
1212
<ng-container ngProjectAs="[minus]">
1313
<ng-template let-step="step" let-min="min" let-value="value">
14-
<svg *ngIf="custom !== min + step" xmlns="http://www.w3.org/2000/svg" fill="none" viewBox="0 0 24 24" stroke-width="1.5" stroke="currentColor" class="w-6 h-6">
14+
@if(custom !== min + step) {
15+
<svg xmlns="http://www.w3.org/2000/svg" fill="none" viewBox="0 0 24 24" stroke-width="1.5" stroke="currentColor" class="w-6 h-6">
1516
<path stroke-linecap="round" stroke-linejoin="round" d="M19.5 12h-15" />
1617
</svg>
17-
<svg *ngIf="custom == min + step" xmlns="http://www.w3.org/2000/svg" fill="none" viewBox="0 0 24 24" stroke-width="1.5" stroke="currentColor" class="w-6 h-6">
18+
} @else {
19+
<svg xmlns="http://www.w3.org/2000/svg" fill="none" viewBox="0 0 24 24" stroke-width="1.5" stroke="currentColor" class="w-6 h-6">
1820
<path stroke-linecap="round" stroke-linejoin="round" d="M14.74 9l-.346 9m-4.788 0L9.26 9m9.968-3.21c.342.052.682.107 1.022.166m-1.022-.165L18.16 19.673a2.25 2.25 0 01-2.244 2.077H8.084a2.25 2.25 0 01-2.244-2.077L4.772 5.79m14.456 0a48.108 48.108 0 00-3.478-.397m-12 .562c.34-.059.68-.114 1.022-.165m0 0a48.11 48.11 0 013.478-.397m7.5 0v-.916c0-1.18-.91-2.164-2.09-2.201a51.964 51.964 0 00-3.32 0c-1.18.037-2.09 1.022-2.09 2.201v.916m7.5 0a48.667 48.667 0 00-7.5 0" />
1921
</svg>
22+
}
2023
</ng-template>
2124
</ng-container>
2225
</ngx-input-counter>
@@ -26,24 +29,28 @@ <h2>Custom style</h2>
2629
<h2>Custom style 2</h2>
2730

2831
<!-- <small>Using SVG icons</small> -->
29-
<ng-template #plusTemplateIcon>
32+
<ng-template #plusTemplateIcon>
33+
<svg xmlns="http://www.w3.org/2000/svg" fill="none" viewBox="0 0 24 24" stroke-width="1.5" stroke="currentColor">
34+
<path stroke-linecap="round" stroke-linejoin="round" d="M12 4.5v15m7.5-7.5h-15" />
35+
</svg>
36+
</ng-template>
37+
<ng-template #minusTemplateIcon let-step="step" let-min="min" let-value="value">
38+
@if(custom !== min + step) {
3039
<svg xmlns="http://www.w3.org/2000/svg" fill="none" viewBox="0 0 24 24" stroke-width="1.5" stroke="currentColor">
31-
<path stroke-linecap="round" stroke-linejoin="round" d="M12 4.5v15m7.5-7.5h-15" />
32-
</svg>
33-
</ng-template>
34-
<ng-template #minusTemplateIcon let-step="step" let-min="min" let-value="value">
35-
<svg *ngIf="custom !== min + step" xmlns="http://www.w3.org/2000/svg" fill="none" viewBox="0 0 24 24" stroke-width="1.5" stroke="currentColor">
3640
<path stroke-linecap="round" stroke-linejoin="round" d="M19.5 12h-15" />
3741
</svg>
38-
<svg *ngIf="custom == min + step" xmlns="http://www.w3.org/2000/svg" fill="none" viewBox="0 0 24 24" stroke-width="1.5" stroke="#EF2F35">
42+
} @else {
43+
<svg xmlns="http://www.w3.org/2000/svg" fill="none" viewBox="0 0 24 24" stroke-width="1.5" stroke="#EF2F35">
3944
<path stroke-linecap="round" stroke-linejoin="round" d="M14.74 9l-.346 9m-4.788 0L9.26 9m9.968-3.21c.342.052.682.107 1.022.166m-1.022-.165L18.16 19.673a2.25 2.25 0 01-2.244 2.077H8.084a2.25 2.25 0 01-2.244-2.077L4.772 5.79m14.456 0a48.108 48.108 0 00-3.478-.397m-12 .562c.34-.059.68-.114 1.022-.165m0 0a48.11 48.11 0 013.478-.397m7.5 0v-.916c0-1.18-.91-2.164-2.09-2.201a51.964 51.964 0 00-3.32 0c-1.18.037-2.09 1.022-2.09 2.201v.916m7.5 0a48.667 48.667 0 00-7.5 0" />
4045
</svg>
41-
</ng-template>
46+
}
47+
</ng-template>
4248

4349
<div style="display: flex;">
44-
45-
<ngx-input-counter class="custom-plus" style="margin: auto;" [(ngModel)]="custom" [max]="5" [min]="0" *ngIf="custom>0">
50+
@if (custom > 0) {
51+
<ngx-input-counter class="custom-plus" style="margin: auto;" [(ngModel)]="custom" [max]="5" [min]="0">
4652
</ngx-input-counter>
53+
}
4754
</div>
4855

4956
<h2>Test custom component</h2>

0 commit comments

Comments
 (0)