Reputation: 331
I'm trying to figure out the best way to add a function to the existing ng-click function below that will add a class to the element upon execution.
$ctrl.next = function(id) {
$state.go('individual', {id : id}, {reload : true});
ga.track({
action:'Button click',
label:'Navigation Button Right',
category:'Button'
});
}
Basically this function triggers a state change to the next item in an array that comes from a database and tracks the element clicked.
Upvotes: 1
Views: 394
Reputation: 5059
Without a sample, I am not 100% clear on what you have. This plunker demo shows clicking a button, and changing it's class to make it blue.
JS
app.controller('ctrl',function($scope){
$scope.clickFunction = function(evt) {
angular.element(evt.srcElement).addClass('clicked-button');
}
});
HTML
<div ng-controller='ctrl'>
<button ng-click="clickFunction($event)">Click Me</button>
</div>
Upvotes: 1