Search code examples
angularjs-scope

How to call another scope function in AngularJS


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!


Solution

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