I'm trying to get the name of a button selected in a variable, and do something after (change the content of a <p>
).
<form>
<button name="paypal" class="moyen-payement-button" ng-class="{actif: actifSelected.selectedButton === 1}" ng-click="actifSelected.select(1)">
<img src="images/payement-methods/paypal.svg" alt="Paypal" class="paypal" />
</button>
<button name="creditCard" class="moyen-payement-button" ng-class="{actif: actifSelected.selectedButton === 2}" ng-click="actifSelected.select(2)">
<img src="images/payement-methods/credit-card.svg" alt="Carte de crédit" class="creditCard" />
</button>
</form>
<p>Name of my button: </p>
<p>1</p>
The <p>
with "1" have to change in "2" if the button creditCard is selected, I've find ng-show
/ ng-hide
but I think I can simply modify the content of a <p>
without creating another <p>
?
You can use:
<button ng-click="actifSelected.select($event,1)"></button>
And in your controller, you can use $event to trigger element
$scope.actifSelected.select = function($event, value) {
var button = angular.element($event.currentTarget);
var buttonName = button.attr("name");
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With