[ ] Bug report
[x] Feature request
[ ] Documentation issue or request
[ ] Regression (a behavior that used to work and stopped working in a new release)
[ ] Support request => Please do not submit support request here
It's much easier and instinctive to specify an attribute for applying it (rather than strip it).
Consider:
<!-- truthy -->
<nz-cascader></nz-cascader>
<!-- falsy -->
<nz-cascader [nzShowInput]="false" [nzShowArrow]="false"></nz-cascader>
Versus:
<!-- truthy -->
<nz-cascader></nz-cascader>
<!-- falsy -->
<nz-cascader [nzNoInput]="true" [nzNoArrow]="true"></nz-cascader>
The latter can then be simplified to:
<!-- truthy -->
<nz-cascader></nz-cascader>
<!-- falsy -->
<nz-cascader nzNoInput nzNoArrow></nz-cascader>
This way we could keep consistency with HTML boolean attributes, and the value part could always be omitted while remain effective.
It can make non-binding usage much simpler. For binding usage, just need to add or remove an ! operator.
Angular version: X.Y.Z
ng-zorro-antd version: X.Y.Z
Browser:
- [ ] Chrome (desktop) version XX
- [ ] Firefox version XX
- [ ] Safari (desktop) version XX
- [ ] IE version XX
For Tooling issues:
- Node version: XX
- Platform:
Others:
这种用法会混淆 Directive 和 Input,感觉用起来怪怪的。
@ghost Haven't you used disabled on <input>? This is the suggested way in most React libs (including antd) and Angular libs (including this one), just trying to make it applicable for more components.
@trotyl what if user want to dynamic change the attribute
@vthinkxie Will keep the same behavior as input[disabled], namely:
<input disabled>
<nz-cascader nzNoInput nzNoArrow></nz-cascader>
Are used for static mockup, while:
<input [disabled]="condition">
<nz-cascader [nzNoInput]="condition" [nzNoArrow]="condition"></nz-cascader>
Applies to dynamic binding.
The only change is that if user writes condition before, they need to use !condition now, and vice versa.
Currently if some user want to use only static markup, they still need to manually binds to a false value, like:
<nz-cascader [nzShowInput]="false" [nzShowArrow]="false"></nz-cascader>
That's too much boilerplate.
@trotyl
Some components are designed as your description already, but change all boolean attribute false by default will bring some break changes, would you please figure out these changes?
@vthinkxie I'll have a thorough check.
Boolean inputs with true by default (so must have a value):
NzCalendarComponent#nzClearTimeNzCalendarComponent#nzFullScreenNzCalendarComponent#nzShowHeaderNzCardComponent#nzBorderedNzCarouselComponent#nzDotsNzCascaderComponent#nzShowInputNzCascaderComponent#nzAllowClearNzCascaderComponent#nzShowArrowNzCascaderComponent#nzEnableCacheNzConfirmComponent#nzMaskClosableNzDatePickerComponent#nzAllowClearNzDropDownComponent#nzClickHideNzDropDownButtonComponent#nzClickHideNzMenuComponent#nzClickActiveNzModalComponent#nzClosableNzModalComponent#nzMaskClosableNzProgressComponent#nzShowInfoNzSelectComponent#nzFilterNzSliderComponent#nzIncludedNzSpinComponent#nzSpinningNzTabsNavComponent#nzAnimatedNzTabsNavComponent#nzShowPaginationNzTabSetComponent#nzAnimatedNzTabSetComponent#nzShowPaginationBoolean inputs with false by default (but not support no value):
NzAlertComponent#nzBannerNzAlertComponent#nzCloseableNzAlertComponent#nzShowIconNzBadgeComponent#nzDotNzButtonComponent#nzGhostNzButtonComponent#nzLoadingNzCalendarComponent#nzDatePickerNzCardComponent#nzLoadingNzCardComponent#nzNoHoveringNzCarouselComponent#nzAutoPlayNzCarouselComponent#nzVerticalNzCascaderComponent#nzDisabledNzCascaderComponent#nzShowSearchNzCascaderComponent#nzChangeOnSelectNzCheckboxGroupComponent#nzDisabledNzCheckboxGroupComponent#nzIndeterminateNzCollapseComponent#nzDisabledNzCollapseComponent#nzActiveNzConfirmComponent#nzVisibleNzConfirmComponent#nzConfirmLoadingNzDropDownButtonComponent#nzDisableNzDropDownButtonComponent#nzVisibleNzDropDownComponent#nzVisibleNzModalComponent#nzVisibleNzModalComponent#nzConfirmLoadingNzMenuItemComponent#nzDisableNzMenuItemComponent#nzSelectedNzMenuComponent#nzInlineCollapsedNzOptionComponent#nzDisabledNzPopconfirmComponent#nzConditionNzRadioButtonComponent#nzDisabledNzRadioComponent#nzCheckedNzRadioComponent#nzDisabledNzRateComponent#nzDisabledNzRowExpandIconComponent#nzExpandNzRowExpandIconComponent#nzShowExpandNzSelectComponent#nzShowSearchNzSelectComponent#nzDisabledNzSelectComponent#nzOpenNzSiderComponent#nzCollapsedNzSliderMarksComponent#nzVerticalNzSliderMarksComponent#nzIncludedNzSliderStepComponent#nzVerticalNzSliderStepComponent#nzIncludedNzSliderTrackComponent#nzVerticalNzSliderTrackComponent#nzIncludedNzSliderComponent#nzDisabledNzSliderComponent#nzDotsNzStepsComponent#nzProgressDotNzSubMenuComponent#nzOpenNzSwitchComponent#nzDisabledNzTableComponent#nzBorderedNzTableComponent#nzCustomNoResultNzTableComponent#nzLoadingNzTableComponent#nzShowSizeChangerNzTableComponent#nzShowQuickJumperNzTableComponent#nzShowTotalNzTableComponent#nzShowFooterNzTableComponent#nzShowTitleNzTdDirective#nzCheckboxNzTdDirective#nzExpandNzThDirective#nzCheckboxNzThDirective#nzExpandNzTabLabelDirective#disabledNzTabsInkBarDirective#nzAnimatedNzTabsNavComponent#nzHideBarNzTabSetComponent#nzHideNzCheckableTagComponent#nzCheckedNzCheckableTagComponent#nzClosableNzTagComponent#nzClosableNzTimePickerInnerComponent#nzDisabledNzTimePickerComponent#nzDisabledBoolean inputs already supports no value truthy:
NzBadgeComponent#nzShowZeroNzFormControlComponent#nzHasFeedbackNzSiderComponent#nzCollapsibleNzPaginationComponent#nzShowSizeChangerNzPaginationComponent#nzShowQuickJumperNzPaginationComponent#nzShowTotalNzPaginationComponent#nzSimpleNzRateComponent#nzAllowHalfNzSelectComponent#nzAllowClearNzSelectComponent#nzKeepUnListOptionsNzSliderComponent#nzVerticalNzTableComponent#nzIsPaginationNzTableComponent#nzIsPageIndexResetNzTimePickerInnerComponent#nzHideDisabledOptions@trotyl
it seems that many break changes will happened if make all boolean attribute false by default
what about make all boolean inputs with false by default support no value truthy first
and the bring the break change in the further version such as 0.6.x or 0.7.x
Actually we don't need to remove the old ones (in near future), it's easy to provide different getter/setter with the same internal.
@trotyl
that is ok, we can give a warning or something before we remove the old ones.
Waiting for https://github.com/angular/angular/issues/19929.
Update: since no quick response there, will use NgModel#disabled implementation for reference.
import { toBoolean } from '../util/convert';
Maybe much better in this way:
import {coerceBooleanProperty, coerceNumberProperty} from '@angular/cdk/coercion';
@cipchk Agree with that.
done with @InputBoolean in the latest version.
Most helpful comment
@ghost Haven't you used
disabledon<input>? This is the suggested way in most React libs (including antd) and Angular libs (including this one), just trying to make it applicable for more components.