0% found this document useful (0 votes)
31 views8 pages

Angular Modules Controllers

Angular modules are collections of controllers, directives, filters, and services that are used to organize code and bootstrap Angular applications. Controllers are JavaScript objects that expose variables and functions to templates and directives. A controller is defined using the ng-Controller directive on an HTML element and added to a module by calling the controller method on the module.

Uploaded by

Florin Voicu
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
31 views8 pages

Angular Modules Controllers

Angular modules are collections of controllers, directives, filters, and services that are used to organize code and bootstrap Angular applications. Controllers are JavaScript objects that expose variables and functions to templates and directives. A controller is defined using the ng-Controller directive on an HTML element and added to a module by calling the controller method on the module.

Uploaded by

Florin Voicu
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 8

Angular

Modules and Controllers


Jogesh K. Muppala

Angular and MVC


Angular is built with MVC in mind
MVC
MVVM
MVW (model-view-whatever)
Model, View and something in between
http://www.beyondjava.net/blog/model-view-whatever/

Angular Modules
An Angular module is a collection of:

Controllers
Directives
Filters
Services
Other configuration information

Bootstrapping your application


Keep your code organized, maintaintable, and testable

Angular Modules
<html ngApp=confusionApp>
. . .
<body>
. . .
<script>
var app = angular.module(confusionApp,[]);
</script>
</body>
</html>

Angular Controller
JavaScript object containing
attributes/properties and functions
Exposes variables and functionality to
expressions and directives

Angular Controller
Controller defined using a ng-controller directive
on an HTML element
Example:
<div class="row row-content"
ng-controller="menuController as menuCtrl">
</div>

Angular Controllers
Add the controller code:

<script>
var app = angular.module('confusionApp',[]);
app.controller('menuController', function() {
});
</script>

Exercise: Angular Modules and Controllers


Define an Angular module, and initialize the
Angular app with the module
Define a controller within your Angular app
and use the controller within your application

You might also like