TheCurious
TheCurious

Reputation: 613

how the flow of execution in callback function?

I got confused when ever there is a call back function.

for example-

<div ng-app="myApp" ng-controller="myCtrl">
Name: <input type="text" ng-model="name"><br>
</div>

<script>
angular.module('myApp', []).controller('myCtrl', function($scope) {
    $scope.name= "John";
});
</script>

I want to know in <script> tag which function will execute first,& also want to make sure is this function return any value to some other function which is used as parameter?

Upvotes: 0

Views: 446

Answers (1)

user937999
user937999

Reputation:

If I'm not wrong, I think you are asking about Method Chaining. Read about it here

Method chaining - why is it a good practice, or not?

In your case, the module function will be executed first. The object it returns has a function called controller which will be executed second.

The callback function will be called only when Angular sees ng-controller="myctrl" directive.

Upvotes: 2

Related Questions