Home > Software engineering >  Is the a way to pass multiple parameters in Angular using click()
Is the a way to pass multiple parameters in Angular using click()

Time:12-26

I would like to know if there is a way of passing parameters on click() in Angular.

      a  asp-action="CreateSales"  
      (click) = "CreateSales(productname='pa', price='16.5')" >

        Some Text

        </a>

I am new to Angular can anyone help?

CodePudding user response:

Just use the variables in html:

<a (click)="CreateSales(param1, param2, param3)">Some Text</a>

for example

<a (click)="CreateSales(1, 'hello', 'world')">Some Text</a>

CodePudding user response:

While everyone who’s worked on a web development project in the past has had to deal with the onClick event (whether it was using React, Vue or even Vanilla JS) going beyond the basic functionality of calling a simple function to deal with the event object is not that trivial.

In this example-based article I want to quickly cover different ways to send multiple parameters to your event handling function without having to sell your soul to Satan.

CodePudding user response:

You can use it like,

<a (click)="CreateSales(param1, param2, param3)">Some Text

  • Related