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

Events like chnage,focus,blur,input working in prime Ng autocomplete #617

Closed
Akanksha-26 opened this issue Jul 18, 2016 · 1 comment
Closed

Comments

@Akanksha-26
Copy link

I am trying to pass changes of autocomplete child component to parent component using event emitter,It is working fine when i use (onSelect) event of autocomplete I am able to pass changes in model to parent component but i also want to pass changes of ng model to parent on blur event also.Below is my child component code .I want to use (blur) event instead of (onSelect).

@Component({ selector: 'product-name-autoComplete', directives: [AutoComplete], template:
< p-autoComplete (change)="setLabel(product)" [(ngModel)]="product" [suggestions]="filteredData" (completeMethod)="filterData($event)" [size]="30"
[minLength]="1" placeholder="Enter Product Name" [dropdown]="false" field="name" >
< template let-brand >
< li class="ui-autocomplete-list-item ui-helper-clearfix">
< div style="float:left">{{brand.name}}< /div >
< /li >
< /template >
< /p-autoComplete >
, providers: [HTTP_PROVIDERS] })

`export class productAutocomplete {
@input() products: any[];
@output() onChange = new EventEmitter();

filteredData : any[];
product: any;
code: number;

filterData (event) {
    this.filteredData = [];
    for (let i = 0; i < this.products.length; i++) {
        let brand = this.products[i].name;
        let code = this.products[i].id;
        if ( brand.toLowerCase().indexOf( event.query.toLowerCase() ) == 0) {
            this.filteredData.push ({
                name: brand,
                id: code,
            });
        }
    }
}
setLabel (product) {
    if (product.name) {
        this. onChange. emit(product);
    }
}

}
`

@cagataycivici
Copy link
Member

cagataycivici commented Mar 22, 2017

Blur is fixed via;

#2256

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants