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

How to use focus event on nz-input ? #73

Closed
cipchk opened this issue Aug 17, 2017 · 2 comments · Fixed by #80
Closed

How to use focus event on nz-input ? #73

cipchk opened this issue Aug 17, 2017 · 2 comments · Fixed by #80

Comments

@cipchk
Copy link
Member

cipchk commented Aug 17, 2017

I'm submitting a...


[ ] Bug report  
[ ] Feature request
[ ] Documentation issue or request
[ ] Regression (a behavior that used to work and stopped working in a new release)
[x] Support request => Please do not submit support request here

Current behavior

I try to set focus on a nz-input component using (focus)="onFocus()" but anything happens!

<nz-input [nzPlaceHolder]="'input search text'" [(ngModel)]="q" (focus)="onFocus()" (blur)="onBlur()">
    <ng-template #prefix>
        <i class="anticon anticon-search"></i>
    </ng-template>
</nz-input>

but……

Do you believe in magic?

Yes!!

so, i found a solution:

-- in typescript
ngOnInit() {
    setTimeout(() => {
        this.qIpt._renderer.listen(this.qIpt._el.querySelector('input'), 'focus', () => {
            this.focus = true;
        });
        this.qIpt._renderer.listen(this.qIpt._el.querySelector('input'), 'blur', () => {
            this.focus = false;
        });
    }, 500);
}
-- in html
<nz-input #qIpt [nzPlaceHolder]="'input search text'" [(ngModel)]="q"></nz-input>

although resolved!!!

do you have anything simpler solution?

@vthinkxie
Copy link
Member

todo: provide nzFocus event next version

@lock
Copy link

lock bot commented Feb 19, 2019

This thread has been automatically locked because it has not had recent activity. Please open a new issue for related bugs and link to relevant comments in this thread.

@lock lock bot locked as resolved and limited conversation to collaborators Feb 19, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants