0% found this document useful (0 votes)
18 views

Controller in Angular

A module in AngularJS is a container for parts of an application like controllers, services, directives and filters. It acts as the main entry point and wires these parts together. To create a module, use the angular.module method, passing the module name and any dependencies. A controller is a JavaScript function that builds a model for the view to display by attaching the model to the $scope object, which makes it available to the view.

Uploaded by

nareshmca123
Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
18 views

Controller in Angular

A module in AngularJS is a container for parts of an application like controllers, services, directives and filters. It acts as the main entry point and wires these parts together. To create a module, use the angular.module method, passing the module name and any dependencies. A controller is a JavaScript function that builds a model for the view to display by attaching the model to the $scope object, which makes it available to the view.

Uploaded by

nareshmca123
Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 1

What is module in AngularJS

A Module is container for different part of the application i.e controllers, Services,
directives, Filters, etc
Why module is needed
You can think of a module as Main() method in other applications which is entry
point into the application and its responsibility of main method to wire the different
parts of the applications
How to create a module
Use the angular objects module method to create a module
Var myApp = angulr.module(myModule, [ ]);
Here angular object is provided by Angular itself, in this module method it have
two parameters , myModule is the name of the module and other parameter [ ]
is the dependencies of the module.
What is the controller in Angular
In angular Controller is a JavaScript function. The job of the controller is to build a
model for the view to display
In real world application a controller may call web service which retrieve data from
the database
How to create a controller in Angular
Var myController = function($scope){
$scope.message = AngularJS tutorial;
}
Notice here we are passing $scope to the function, it is an angular object pass to
this controller function by automatically, we attach the model to the $scope object
then it will available in the View

Controller in Angular
The job of the controller is to build a model for the view , the controller does this by
attaching model to the $scope, here the $scope is not the model whatever the data
we are attaching to the $scope is the model

You might also like