Intellipaat Back

Explore Courses Blog Tutorials Interview Questions
0 votes
2 views
in Web Technology by (47.6k points)

I've been looking for how to execute this but I can't find anything related so far, :( I could nest both functions, yes but I'm just wondering if this is possible? I'd like to do this literally:

<td><button class="btn" ng-click="edit($index) open()">Open me!</button></td>

My JS code at the moment:

$scope.open = function () {

$scope.shouldBeOpen = true;

};

$scope.edit = function(index){

var content_1, content_2;

content_1 = $scope.people[index].name;

content_2 = $scope.people[index].age;

console.log(content_1);

};

I'd like to call two functions with just one click, how can I do this in angularJS? I thought it'd be straight forward like in CSS when you add multiple classes...but it's not :(

1 Answer

0 votes
by (106k points)

To add many features in one ng-click you have two options:-

  • You need to create a third method that wraps both methods. The advantage here is that you put less logic in your template.

  • Another thing you want to add 2 calls in ng-click you can add ';' after edit($index) like this: ng-click="edit($index); open()"

Related questions

+1 vote
1 answer
0 votes
1 answer
+2 votes
1 answer
0 votes
1 answer
+2 votes
1 answer

31k questions

32.8k answers

501 comments

693 users

Browse Categories

...