Skip to content

Commit 4c71bdb

Browse files
konossowossowski
andauthored
feat(module:switch): add nzId input (#6815)
* feat(module:switch): add nzId input * docs(module:switch): documentation update Co-authored-by: ossowski <ossowski@pdtec.de>
1 parent 254b429 commit 4c71bdb

3 files changed

Lines changed: 4 additions & 0 deletions

File tree

components/switch/doc/index.en-US.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ import { NzSwitchModule } from 'ng-zorro-antd/switch';
2222

2323
| Property | Description | Type | Default | Global Config |
2424
| -------- | ----------- | ---- | ------- | ------------- |
25+
| `[nzId]` | button id attribute inside the component| `string` | - |
2526
| `[ngModel]` | determine whether the `nz-switch` is checked, double binding | `boolean` | `false` |
2627
| `[nzCheckedChildren]` | content to be shown when the state is checked | `string \| TemplateRef<void>` | - |
2728
| `[nzUnCheckedChildren]` | content to be shown when the state is unchecked | `string \| TemplateRef<void>` | - |

components/switch/doc/index.zh-CN.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ import { NzSwitchModule } from 'ng-zorro-antd/switch';
2323

2424
| 参数 | 说明 | 类型 | 默认值 | 全局配置 |
2525
| --- | --- | --- | --- | --- |
26+
| `[nzId]` | 组件内部 button 的 id 值 | `string` | - |
2627
| `[ngModel]` | 指定当前是否选中,可双向绑定 | `boolean` | `false` |
2728
| `[nzCheckedChildren]` | 选中时的内容 | `string \| TemplateRef<void>` | - |
2829
| `[nzUnCheckedChildren]` | 非选中时的内容 | `string \| TemplateRef<void>` | - |

components/switch/switch.component.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,7 @@ const NZ_CONFIG_MODULE_NAME: NzConfigKey = 'switch';
5151
type="button"
5252
class="ant-switch"
5353
#switchElement
54+
[attr.id]="nzId"
5455
[disabled]="nzDisabled"
5556
[class.ant-switch-checked]="isChecked"
5657
[class.ant-switch-loading]="nzLoading"
@@ -91,6 +92,7 @@ export class NzSwitchComponent implements ControlValueAccessor, AfterViewInit, O
9192
@Input() nzCheckedChildren: string | TemplateRef<void> | null = null;
9293
@Input() nzUnCheckedChildren: string | TemplateRef<void> | null = null;
9394
@Input() @WithConfig() nzSize: NzSizeDSType = 'default';
95+
@Input() nzId: string | null = null;
9496

9597
dir: Direction = 'ltr';
9698

0 commit comments

Comments
 (0)