Search within TutorialsPark

AngularJS Multiple and Scopeless Controllers

Learn How to Oraganize Multiple Controllers and Scopeless Controllers in your Application

AngularJS Controllers : Multiple Controllers

An AngularJS application can contain as many controllers as needed, a good approach is to create a new controller for every significant view within the application, inorder to keep the code easy to maintain and upgrade.

In the example, there are two controllers independent of each other, none of the controllers share scopes or inherit any data or behaviours.

Example: AngularJS Controller Organization Multiple Controllers

Give it a TRY! » Note:The first controller reverses the text, while the second one convert input to uppercase.

AngularJS Controller Organization : Controllers without any Scope

If an application does not depend upon communication with other controllers, or does not require any inheritance feature, you can use Scopeless Controllers

In the demo, the data and behaviour of the controller is defined using JavaScript, no dependency on $scope

Example: AngularJS Controller Organization Controllers without Scope

Give it a TRY! » Note: Scopeless Controllers are useful for small applications, to avoid complexities.