How to call another scope function in AngularJS

Tom Cheng picture Tom Cheng · Jul 18, 2013 · Viewed 67.4k times · Source

In AngularJS, I have 2 scope function in the controller,

$scope.fn1 = function(){
//do something A
};

$scope.fn2 = function(){
    //do something B
    //I want to call fn1 here.
};

If my fn2 want to call fn1, how can I do? Thanks!

Answer

Yann picture Yann · Jul 18, 2013

Since both functions are in the same scope you can simply call $scope.fn1() inside fn2.