We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
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
场景一,通过指令,为表单控件设置默认的提示信息
import {Directive, Optional} from '@angular/core'; import {TiSelectComponent, TiTextComponent, TiValidationDirective} from "@opentiny/ng"; @Directive({ selector: 'ti-select[formControlName],input[tiText][formControlName]', standalone: true, host: { "[style.width.px]": "240" }, hostDirectives: [ // TiValidationDirective ] }) export class DefaultDirective { constructor( @Optional() private tiValidationDirective: TiValidationDirective, @Optional() private tiSelect: TiSelectComponent, @Optional() private tiInput: TiTextComponent, ) { if (tiSelect) { tiSelect.placeholder = "Please Choose"; } if (tiInput) { tiInput.nativeElement.placeholder = "Please Input"; } if (tiValidationDirective) { tiValidationDirective.tiValidation = { tip: "Required", tipPosition: "right" }; } } }
如上指令,目前由于TiValidationDirective是非“standalone”的,为了给tiValidationDirective设置默认值,我需要对每个控件都添加tiValidation。 例如:
<ti-formfield [formGroup]="formGroup"> <ti-item [label]="'Country'" [required]="true"> <ti-select country formControlName="country" tiValidation></ti-select> </ti-item> <ti-item [label]="'Name'" [required]="true"> <input formControlName="name" tiText tiValidation/> </ti-item> </ti-formfield>
预期给TiValidationDirective迁移至standalone后,可以通过hostDirectives组合,如:
@Directive({ selector: 'ti-select[formControlName],input[tiText][formControlName]', hostDirectives: [{ directive: TiValidationDirective, inputs: ["tiValidation"], }] }) export class DefaultDirective { // ... }
html中就不需要每个控件都指定tiValidation
<ti-formfield [formGroup]="formGroup"> <ti-item [label]="'Country'" [required]="true"> <ti-select country formControlName="country"></ti-select> </ti-item> <ti-item [label]="'Name'" [required]="true"> <input formControlName="name" tiText/> </ti-item> </ti-formfield>
The text was updated successfully, but these errors were encountered:
No branches or pull requests
What problem does this feature solve
场景一,通过指令,为表单控件设置默认的提示信息
如上指令,目前由于TiValidationDirective是非“standalone”的,为了给tiValidationDirective设置默认值,我需要对每个控件都添加tiValidation。
例如:
What does the proposed API look like
预期给TiValidationDirective迁移至standalone后,可以通过hostDirectives组合,如:
html中就不需要每个控件都指定tiValidation
The text was updated successfully, but these errors were encountered: