ChrisM ChrisM - 7 months ago 117
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>
</a>
</div>


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

How do I combine the two?

Thanks

Answer

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>
</div>

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

Comments