Reputation: 322
I have a problem with this:
@Output() searchFilter = new EventEmitter<string>();
then
filter() {
this.searchFilter.emit('soy un emit');}
And in the view I call this :
<input type="text" class="form-control" placeholder="Buscar" [(ngModel)]="searchFilter" (input)="filter()" >
In the parent
<app-header (searchFilter)="filter($event)"></app-header>
This code works without problems in other project but now this gives me the following error
ERROR TypeError: this.searchFilter.emit is not a function
Any idea?
Upvotes: 2
Views: 387
Reputation: 657048
[(ngModel)]="searchFilter"
causes a string from the input element to be assigned to searchFilter
and a string doesn't have an emit
method.
It's not entirely clear what you try to accomplish to give more concrete advice to fix your problem.
A guess
@Output() searchFilterChange = new EventEmitter<string>();
@Input() searchFilter:string;
filter() {
this.searchFilterChange.emit('soy un emit');
}
<input type="text" class="form-control" placeholder="Buscar"
[ngModel]="searchFilter" (ngModelChange)="filter()" >
Upvotes: 1