After spending hours on this, I apologize if this is a silly question but is there a method in AngularJS or Javascript to achieve the following:
HTML // I have various HTML code pieces (templates) for different controls
<button data-action="flip" ng-click="imageControl($event)"></button>
// ... 10 other types of image controls like rotate, etc.
// Goal - display or hide HTML based on the button pressed
<div ng-show="(imageControl.flip)> // html stuff </div>
// Angular function
$scope.imageControl = function($event) {
// get data-action from the HTML element e.g. flip
var actionType = $event.currentTarget.getAttribute("data-action");
$scope.actionType ? $scope.actionType = false : $scope.actionType = true;
}
HERE IS THE QUERY:
Is there a way for me to dynamically create and set a variable using actionType? Why? So I don't have to create 10 different if statements for each control. By the way, I understand this may not work, but it's just an example to illustrate my point.