Skip to content

Commit

Permalink
feat(module:switch): add nzId input (#6815)
Browse files Browse the repository at this point in the history
* feat(module:switch): add nzId input

* docs(module:switch): documentation update

Co-authored-by: ossowski <ossowski@pdtec.de>
  • Loading branch information
konossow and ossowski authored Jul 25, 2022
1 parent 254b429 commit 4c71bdb
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 0 deletions.
1 change: 1 addition & 0 deletions components/switch/doc/index.en-US.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ import { NzSwitchModule } from 'ng-zorro-antd/switch';

| Property | Description | Type | Default | Global Config |
| -------- | ----------- | ---- | ------- | ------------- |
| `[nzId]` | button id attribute inside the component| `string` | - |
| `[ngModel]` | determine whether the `nz-switch` is checked, double binding | `boolean` | `false` |
| `[nzCheckedChildren]` | content to be shown when the state is checked | `string \| TemplateRef<void>` | - |
| `[nzUnCheckedChildren]` | content to be shown when the state is unchecked | `string \| TemplateRef<void>` | - |
Expand Down
1 change: 1 addition & 0 deletions components/switch/doc/index.zh-CN.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ import { NzSwitchModule } from 'ng-zorro-antd/switch';

| 参数 | 说明 | 类型 | 默认值 | 全局配置 |
| --- | --- | --- | --- | --- |
| `[nzId]` | 组件内部 button 的 id 值 | `string` | - |
| `[ngModel]` | 指定当前是否选中,可双向绑定 | `boolean` | `false` |
| `[nzCheckedChildren]` | 选中时的内容 | `string \| TemplateRef<void>` | - |
| `[nzUnCheckedChildren]` | 非选中时的内容 | `string \| TemplateRef<void>` | - |
Expand Down
2 changes: 2 additions & 0 deletions components/switch/switch.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@ const NZ_CONFIG_MODULE_NAME: NzConfigKey = 'switch';
type="button"
class="ant-switch"
#switchElement
[attr.id]="nzId"
[disabled]="nzDisabled"
[class.ant-switch-checked]="isChecked"
[class.ant-switch-loading]="nzLoading"
Expand Down Expand Up @@ -91,6 +92,7 @@ export class NzSwitchComponent implements ControlValueAccessor, AfterViewInit, O
@Input() nzCheckedChildren: string | TemplateRef<void> | null = null;
@Input() nzUnCheckedChildren: string | TemplateRef<void> | null = null;
@Input() @WithConfig() nzSize: NzSizeDSType = 'default';
@Input() nzId: string | null = null;

dir: Direction = 'ltr';

Expand Down

0 comments on commit 4c71bdb

Please sign in to comment.