Everything in an AngularJS application passes through a controller. Dependency injection is used to add the needed dependencies. See given example.
This tells how to create a new controller:
/* Comment */
- In above code first I created a new model : addonsController (Using call to module method of angulaJS)
- Then I created a new controller: addonsCtrl (By Calling the controller of above module)
- So we created all controllers which will be added in addonsControllers module.
This controller plays an important role in the Application. It represents many dependencies. It also has some primary responsibilities, which will explore in next article.
So this is the simple method by which we can create a new controller in AngularJS.