JacobIRR JacobIRR - 3 years ago 164
AngularJS Question

Pass dynamic values to ng-click?

When I do this, site works in the tag, but it throws an error for the function args. When I only use one set of braces, nothing shows there. What is the proper way to set these dynamic function args in a view?

<a ng-click="viewThisGraph({{site}}, {{cur_action}})" href="#">{{site}}</a>

Answer Source

You should be pass variable without {{}}(interpolation)

ng-click="viewThisGraph(site, cur_action)" 

Also remove href="#" from the anchor, which will prevent unnecessary route navigation to default state.

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download