我将这些值用于函数:
component.ts
ubicacion = 'Cusco';
categoria = 'Arte y Antiguedades';
getAvisos() {
this.avisos = this.fs.filterByAll(this.ubicacion, this.categoria);
}
但是因为我想要改变这些值(ubicacion
和categoria
)我正在尝试这个:
component.html
<input type="text" [(ngModel)]="ubicacion" [ngValue]="Cusco"/>
<input type="text" [(ngModel)]="categoria" [ngValue]="Arte y Antiguedades"/>
component.ts
ubicacion;
categoria;
getAvisos() {
this.avisos = this.fs.filterByAll(this.ubicacion, this.categoria);
}
但是我收到以下错误:
Can't bind to 'ngValue' since it isn't a known property of 'input'
我该如何解决?
答案 0 :(得分:0)
您不应同时使用 ngValue
和 ngModel
,将ngModel与ngModelChange一起使用。
<input type="text" [(ngModel)]="ubicacion"/>
<input type="text" [(ngModel)]="categoria" />