Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(module:switch): add nzId input #6815

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
1 change: 1 addition & 0 deletions components/switch/doc/index.en-US.md
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
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
Expand Up @@ -50,6 +50,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 @@ -94,6 +95,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