Join the Stack Overflow Community
Stack Overflow is a community of 6.4 million programmers, just like you, helping each other.
Join them; it only takes a minute:
Sign up

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!

share|improve this question
up vote 72 down vote accepted

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

share|improve this answer
1  
Thanks for your answer – Tom Cheng Jul 18 '13 at 14:35
34  
Fn1() must be declared before call it on fn2() – RolandoCC May 20 '14 at 20:28
1  
@RolandoCC Thanks alot. I was so sure how to call it but this have to declare before was killing me -*- – cjmling May 19 '15 at 5:41
1  
@RolandoCC how to declare it ?? – Melvin Nov 19 '15 at 9:45
2  
@Melvin just : $scope.fn1 = function(){ }; – RolandoCC Nov 19 '15 at 14:49

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.