ngModel ngValue更改参数值函数

时间:2018-05-25 02:29:13

标签: angular

我将这些值用于函数:

component.ts

ubicacion = 'Cusco';
categoria = 'Arte y Antiguedades';


getAvisos() {
  this.avisos = this.fs.filterByAll(this.ubicacion, this.categoria);
}

但是因为我想要改变这些值(ubicacioncategoria)我正在尝试这个:

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'

我该如何解决?

1 个答案:

答案 0 :(得分:0)

您不应同时使用 ngValue ngModel ,将ngModel与ngModelChange一起使用。

<input type="text" [(ngModel)]="ubicacion"/>
<input type="text" [(ngModel)]="categoria" />