HiPownedBi
HiPownedBi

Reputation: 195

call multiple functions by order use ng-click, single click and pass the same variable to multiple functions angularjs

ng-click cannot call googlesearch function and keywordsearch fuction.

How to call two functions ng-click??? i would like to know how to create the single click, but run two functions by order.

for example:

That is on single click first function(googlesearch) executes

and then second function(keywordsearch) executes respectively.

html

<div class="test" ng-controller="Ctrl">
  <input tpye="text" ng-model="keyword"/>
   <button ng click="googlesearch(keyword);keywordsearch(keyword)">search</button>
  </div>
<div>

angularjs

var app = angular.module('app', []);

function Ctrl($scope) {

    $scope.googlesearch=function(keyword){
    alert("do the googlesearch 1 "+keyword);
  };

   $scope.keywordsearch=function(keyword){
    alert("do the keywordsearch 2 "+keyword);
  };


}

Upvotes: 0

Views: 458

Answers (1)

Sajeetharan
Sajeetharan

Reputation: 222582

Call the second function inside your first one,

$scope.googlesearch=function(keyword){
    alert("do the googlesearch 1 "+keyword);
    $scope.keywordsearch(keyword);
  };

Upvotes: 2

Related Questions