ChrisM ChrisM - 2 years ago 228
Javascript Question

Use ng-click with data-ng-href

I'm trying to have a button that brings a user to the product details but id also like the button to increment a counter through an ng-click function

<div class="row center-block save-button" >
<a data-ng-href="/savings/{{saving._id}}" >
<md-button aria-label="button" ng-click="upVoteHome(saving)" type="button" class="save-button-md">Save</md-button>

The ng-click here has no effect and never cllas the function.

How do I combine the two?


Answer Source

do this:

<div class="row center-block save-button" >
        <md-button aria-label="button" ng-click="upVoteHome(saving, {{saving._id}})" type="button" class="save-button-md">Save</md-button>

and then in the upVoteHome function incremment the counter and then redirect to the url that is passed.

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