Skip to content

Commit

Permalink
refactor(module:radio): use the new control flow (#8480)
Browse files Browse the repository at this point in the history
  • Loading branch information
Nicoss54 committed Apr 5, 2024
1 parent 5c3c29d commit 0f6c11c
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 9 deletions.
5 changes: 4 additions & 1 deletion components/radio/demo/radiogroup-more.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,9 @@ import { Component } from '@angular/core';
<label nz-radio nzValue="C">Option C</label>
<label nz-radio nzValue="M">
More...
<input type="text" nz-input *ngIf="radioValue === 'M'" />
@if (radioValue === 'M') {
<input type="text" nz-input />
}
</label>
</nz-radio-group>
`,
Expand All @@ -20,6 +22,7 @@ import { Component } from '@angular/core';
height: 32px;
line-height: 32px;
}
input {
width: 100px;
margin-left: 10px;
Expand Down
12 changes: 9 additions & 3 deletions components/radio/demo/radiogroup-options.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,19 @@ import { Component } from '@angular/core';
selector: 'nz-demo-radio-radiogroup-options',
template: `
<nz-radio-group [(ngModel)]="radioValue">
<label nz-radio [nzValue]="o.value" *ngFor="let o of options">{{ o.label }}</label>
@for (o of options; track o.value) {
<label nz-radio [nzValue]="o.value">{{ o.label }}</label>
}
</nz-radio-group>
<nz-radio-group [(ngModel)]="radioValue">
<label nz-radio [nzValue]="o.value" *ngFor="let o of options">{{ o.label }}</label>
@for (o of options; track o.value) {
<label nz-radio [nzValue]="o.value">{{ o.label }}</label>
}
</nz-radio-group>
<nz-radio-group [(ngModel)]="radioValue">
<label nz-radio [nzValue]="o.value" *ngFor="let o of options">{{ o.label }}</label>
@for (o of options; track o.value) {
<label nz-radio [nzValue]="o.value">{{ o.label }}</label>
}
</nz-radio-group>
`
})
Expand Down
15 changes: 10 additions & 5 deletions components/radio/radio.spec.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { BidiModule, Dir } from '@angular/cdk/bidi';
import { ApplicationRef, Component, DebugElement, ViewChild } from '@angular/core';
import { ComponentFixture, TestBed, fakeAsync, flush, tick, waitForAsync } from '@angular/core/testing';
import { ComponentFixture, fakeAsync, flush, TestBed, tick, waitForAsync } from '@angular/core/testing';
import { FormControl, FormsModule, ReactiveFormsModule } from '@angular/forms';
import { By } from '@angular/platform-browser';

Expand Down Expand Up @@ -427,6 +427,7 @@ describe('radio', () => {
});
});
});

@Component({
// eslint-disable-next-line
selector: 'nz-test-radio-single',
Expand Down Expand Up @@ -555,7 +556,9 @@ export class NzTestRadioGroupDisabledComponent {
template: `
<form nz-form>
<nz-radio-group [formControl]="formControl">
<label nz-radio *ngFor="let val of radioValues" [nzValue]="val">{{ val }}</label>
@for (val of radioValues; track val) {
<label nz-radio [nzValue]="val">{{ val }}</label>
}
</nz-radio-group>
</form>
`
Expand Down Expand Up @@ -584,9 +587,11 @@ export class NzTestRadioGroupSolidComponent {
@Component({
template: `
<nz-radio-group>
<label nz-radio *ngFor="let item of items" [nzValue]="item.label" [(ngModel)]="item.checked">
{{ item.label }}
</label>
@for (item of items; track item) {
<label nz-radio [nzValue]="item.label" [(ngModel)]="item.checked">
{{ item.label }}
</label>
}
</nz-radio-group>
`
})
Expand Down

0 comments on commit 0f6c11c

Please sign in to comment.