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

能否让nz-form-control接受自定义的context来让ErrorTip更通用。 #4411

Closed
HHHui opened this issue Nov 8, 2019 · 2 comments
Closed
Assignees
Labels
Component: Form 👨‍🏭 Some one working on this A community member has started working on this

Comments

@HHHui
Copy link

HHHui commented Nov 8, 2019

What problem does this feature solve?

现在的nz-form-control中ErrorTip Template的context中只有当前的FormControl, 如果可以加上自定义的一些属性比如Input的Label,这样模板可以更加通用。

What does the proposed API look like?

<nz-form-item>
  <nz-form-label>IP</nz-form-label>
  <nz-form-control [nzErrorTip]="errorTpl" [nzTplContext]="{name: 'ip'}">
    <input formControlName="ip" nz-input placeholder="please enter ip" />
  </nz-form-control>
</nz-form-item>
<nz-form-item>
  <nz-form-label>Name</nz-form-label>
  <nz-form-control [nzErrorTip]="errorTpl" [nzTplContext]="{name: 'name'}">
    <input formControlName="name" nz-input placeholder="please enter name" />
  </nz-form-control>
</nz-form-item>

<ng-template #errorTpl let-control let-name="name">
  <ng-container *ngIf="control.hasError('required')">
    Please confirm your {{name}}!
  </ng-container>
</ng-template>
```<!-- generated by ng-zorro-issue-helper. DO NOT REMOVE -->
@zorro-bot
Copy link

zorro-bot bot commented Nov 8, 2019

Translation of this issue:

Can let nz-form-control context to accept the custom to make ErrorTip more versatile.

What problem does this feature solve?

context now nz-form-control in ErrorTip Template in only the current FormControl, if you can add some custom properties such as the Input Label, this template can be more versatile.

What does the proposed API look like?

`` `Html

   IP </ nz-form-label>
  <Nz-form-control [nzErrorTip] = "errorTpl" [nzTplContext] = "{name: 'ip'}">
    
  </ Nz-form-control>
</ Nz-form-item>

   Name </ nz-form-label>
  <Nz-form-control [nzErrorTip] = "errorTpl" [nzTplContext] = "{name: 'name'}">
    
  </ Nz-form-control>
</ Nz-form-item>

<Ng-template #errorTpl let-control let-name = "name">
  <Ng-container * ngIf = "control.hasError ( 'required')">
    Please confirm your {{name}}!
  </ Ng-container>
</ Ng-template>
`` `

@wenqi73
Copy link
Member

wenqi73 commented Jan 7, 2020

Please track #4523.

@wenqi73 wenqi73 closed this as completed Jan 7, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Component: Form 👨‍🏭 Some one working on this A community member has started working on this
Projects
None yet
Development

No branches or pull requests

3 participants