Click function with a model variable

Asked

Viewed 31 times

1

Hey, guys, I got a model receiving the value of a web api perfectly, but the problem is that I have a function that needs to catch the value of model and put in the click function as parameter and it gives the following error:

    Uncaught Error: Template parse errors:
Parser Error: Got interpolation ({{}}) where expression was expected at column 13 in [PegarValores({{pesquisas.Codigo}})] in ng:///AppModule/FormpesquisaComponent.html@37:49

I don’t know if I’m calling the model the right way, but I’m going to put the code below the model, and the html for a better understanding of the problem:

HTML

<button class="btn btn-info" (click)="PegarValores({{pesquisas.Codigo}})">
  <i class="glyphicon glyphicon-ok" style="color:green;"></i>Iniciar
</button>

MODEL

export class Pesquisa {
    public Codigo: number;
    public Id: number;
    public Nome: string;
}

1 answer

2


At the angle inside the method does not need the brackets.

<button class="btn btn-info" (click)="PegarValores(pesquisas.Codigo)">
  <i class="glyphicon glyphicon-ok" style="color:green;"></i>Iniciar
</button>
  • Okay, it worked, thanks!!

Browser other questions tagged

You are not signed in. Login or sign up in order to post.