SlideShare a Scribd company logo
2
Most read
3
Most read
5
Most read
CONTROLLERS
Why Controllers?
Use of Global functions is not recommended in Angularjs.
Angularjs follows MVC Architecture so it expects the function to be registered with it before using the function.
Writing or initializing the variable within the HTML tags is not recommended because it has to follow the MVC
standards.
We have to use all the angular features.
EX:<div ng-app="" ng-init="myText=20">//NOT RECOMMENDED
What are Controllers?
Controllers can be defined as the code which will call different functions to get the right data from model
to view.
A Controller is a JavaScript Object created by JavaScript Constructor.It can be mainly used to initialization
means to set the initial state of your $scope object.
It can also be defined as binding data to the View and also handling the data flow into your angular
application.
All the business logics are handled with the controllers in the Angularjs.
How to Use Controller?
A Controller has to be always registered with the module.
The ng-controller defines the application controller.
Before creating a controller we have to create a module and register the controller with it.
Creating a Module
Var modules=angular.module(“myModule”[ ] );
It takes two parameters first one is module name and second one is the array for dependent modules.
How to Use Controller?
Creating Controller:
modules.controller(“myController”,Main);
Here the two parameters are “myController” is the Controller name and Main is the Method name.
Example:
https://codepen.io/nikhil12/pen/qjEewJ
Any Questions?
Thank You
HAVE A GREAT DAY
Ad

Recommended

Angular js getting started
Angular js getting started
Hemant Mali
 
Modules in AngularJs
Modules in AngularJs
K Arunkumar
 
AngularJS
AngularJS
Hiten Pratap Singh
 
Up & running with ECMAScript6
Up & running with ECMAScript6
Nir Kaufman
 
Mvc - Titanium
Mvc - Titanium
Prawesh Shrestha
 
Dive into Angular, part 1: Introduction
Dive into Angular, part 1: Introduction
Oleksii Prohonnyi
 
Angular js
Angular js
sanjay joshi
 
Angular Seminar-js
Angular Seminar-js
Mindfire Solutions
 
Starting with angular js
Starting with angular js
jagriti srivastava
 
Beyond AngularJS: Best practices and more
Beyond AngularJS: Best practices and more
Ari Lerner
 
Dive into Angular, part 3: Performance
Dive into Angular, part 3: Performance
Oleksii Prohonnyi
 
AngularJs Style Guide
AngularJs Style Guide
Chiew Carol
 
Dive into Angular, part 4: Angular 2.0
Dive into Angular, part 4: Angular 2.0
Oleksii Prohonnyi
 
Angularjs PPT
Angularjs PPT
Amit Baghel
 
AngularJS interview questions
AngularJS interview questions
Uri Lukach
 
Introduction to AngularJS Framework
Introduction to AngularJS Framework
Raveendra R
 
Angular Dependency Injection
Angular Dependency Injection
Nir Kaufman
 
Get satrted angular js
Get satrted angular js
Alexandre Marreiros
 
Angular%201%20to%20angular%202
Angular%201%20to%20angular%202
Ran Wahle
 
Introduction to AngularJS
Introduction to AngularJS
Shyjal Raazi
 
Angular js for beginners
Angular js for beginners
Munir Hoque
 
AngularJS Best Practices
AngularJS Best Practices
Betclic Everest Group Tech Team
 
Angular from Scratch
Angular from Scratch
Christian Lilley
 
Dive into Angular, part 5: Experience
Dive into Angular, part 5: Experience
Oleksii Prohonnyi
 
Angular JS Introduction
Angular JS Introduction
Dhyego Fernando
 
Introduction to AngularJS
Introduction to AngularJS
David Parsons
 
Angular EE - Special Workshop by Nir Kaufman
Angular EE - Special Workshop by Nir Kaufman
Nir Kaufman
 
Introduction to Angular js 2.0
Introduction to Angular js 2.0
Nagaraju Sangam
 
Intoduction to Angularjs
Intoduction to Angularjs
Gaurav Agrawal
 
Angularjs overview
Angularjs overview
VickyCmd
 

More Related Content

What's hot (20)

Starting with angular js
Starting with angular js
jagriti srivastava
 
Beyond AngularJS: Best practices and more
Beyond AngularJS: Best practices and more
Ari Lerner
 
Dive into Angular, part 3: Performance
Dive into Angular, part 3: Performance
Oleksii Prohonnyi
 
AngularJs Style Guide
AngularJs Style Guide
Chiew Carol
 
Dive into Angular, part 4: Angular 2.0
Dive into Angular, part 4: Angular 2.0
Oleksii Prohonnyi
 
Angularjs PPT
Angularjs PPT
Amit Baghel
 
AngularJS interview questions
AngularJS interview questions
Uri Lukach
 
Introduction to AngularJS Framework
Introduction to AngularJS Framework
Raveendra R
 
Angular Dependency Injection
Angular Dependency Injection
Nir Kaufman
 
Get satrted angular js
Get satrted angular js
Alexandre Marreiros
 
Angular%201%20to%20angular%202
Angular%201%20to%20angular%202
Ran Wahle
 
Introduction to AngularJS
Introduction to AngularJS
Shyjal Raazi
 
Angular js for beginners
Angular js for beginners
Munir Hoque
 
AngularJS Best Practices
AngularJS Best Practices
Betclic Everest Group Tech Team
 
Angular from Scratch
Angular from Scratch
Christian Lilley
 
Dive into Angular, part 5: Experience
Dive into Angular, part 5: Experience
Oleksii Prohonnyi
 
Angular JS Introduction
Angular JS Introduction
Dhyego Fernando
 
Introduction to AngularJS
Introduction to AngularJS
David Parsons
 
Angular EE - Special Workshop by Nir Kaufman
Angular EE - Special Workshop by Nir Kaufman
Nir Kaufman
 
Introduction to Angular js 2.0
Introduction to Angular js 2.0
Nagaraju Sangam
 
Beyond AngularJS: Best practices and more
Beyond AngularJS: Best practices and more
Ari Lerner
 
Dive into Angular, part 3: Performance
Dive into Angular, part 3: Performance
Oleksii Prohonnyi
 
AngularJs Style Guide
AngularJs Style Guide
Chiew Carol
 
Dive into Angular, part 4: Angular 2.0
Dive into Angular, part 4: Angular 2.0
Oleksii Prohonnyi
 
AngularJS interview questions
AngularJS interview questions
Uri Lukach
 
Introduction to AngularJS Framework
Introduction to AngularJS Framework
Raveendra R
 
Angular Dependency Injection
Angular Dependency Injection
Nir Kaufman
 
Angular%201%20to%20angular%202
Angular%201%20to%20angular%202
Ran Wahle
 
Introduction to AngularJS
Introduction to AngularJS
Shyjal Raazi
 
Angular js for beginners
Angular js for beginners
Munir Hoque
 
Dive into Angular, part 5: Experience
Dive into Angular, part 5: Experience
Oleksii Prohonnyi
 
Introduction to AngularJS
Introduction to AngularJS
David Parsons
 
Angular EE - Special Workshop by Nir Kaufman
Angular EE - Special Workshop by Nir Kaufman
Nir Kaufman
 
Introduction to Angular js 2.0
Introduction to Angular js 2.0
Nagaraju Sangam
 

Similar to Controllers in AngularJs (20)

Intoduction to Angularjs
Intoduction to Angularjs
Gaurav Agrawal
 
Angularjs overview
Angularjs overview
VickyCmd
 
AngularJs (1.x) Presentation
AngularJs (1.x) Presentation
Raghubir Singh
 
Angular js interview question answer for fresher
Angular js interview question answer for fresher
Ravi Bhadauria
 
Kalp Corporate Angular Js Tutorials
Kalp Corporate Angular Js Tutorials
Kalp Corporate
 
One Weekend With AngularJS
One Weekend With AngularJS
Yashobanta Bai
 
AngularJS in practice
AngularJS in practice
Eugene Fidelin
 
Angularjs
Angularjs
Sabin Tamrakar
 
AgularJS basics- angular directives and controllers
AgularJS basics- angular directives and controllers
jobinThomas54
 
Introduction to Angular Js
Introduction to Angular Js
Professional Guru
 
introduction to Angularjs basics
introduction to Angularjs basics
Ravindra K
 
Itroducing Angular JS
Itroducing Angular JS
Carlos Emanuel Mathiasen
 
Introduction to Angularjs
Introduction to Angularjs
Manish Shekhawat
 
Introduction to Angularjs : kishan kumar
Introduction to Angularjs : kishan kumar
Appfinz Technologies
 
Angular js
Angular js
Arun Somu Panneerselvam
 
Introduction of ASP.NET MVC and AngularJS
Introduction of ASP.NET MVC and AngularJS
Mohamed Elkhodary
 
AngularJs Basic Concept
AngularJs Basic Concept
Hari Haran
 
Introduction to AngularJS
Introduction to AngularJS
Collaboration Technologies
 
Angular js
Angular js
vu van quyet
 
Angular Js Get Started - Complete Course
Angular Js Get Started - Complete Course
EPAM Systems
 
Intoduction to Angularjs
Intoduction to Angularjs
Gaurav Agrawal
 
Angularjs overview
Angularjs overview
VickyCmd
 
AngularJs (1.x) Presentation
AngularJs (1.x) Presentation
Raghubir Singh
 
Angular js interview question answer for fresher
Angular js interview question answer for fresher
Ravi Bhadauria
 
Kalp Corporate Angular Js Tutorials
Kalp Corporate Angular Js Tutorials
Kalp Corporate
 
One Weekend With AngularJS
One Weekend With AngularJS
Yashobanta Bai
 
AgularJS basics- angular directives and controllers
AgularJS basics- angular directives and controllers
jobinThomas54
 
introduction to Angularjs basics
introduction to Angularjs basics
Ravindra K
 
Introduction to Angularjs : kishan kumar
Introduction to Angularjs : kishan kumar
Appfinz Technologies
 
Introduction of ASP.NET MVC and AngularJS
Introduction of ASP.NET MVC and AngularJS
Mohamed Elkhodary
 
AngularJs Basic Concept
AngularJs Basic Concept
Hari Haran
 
Angular Js Get Started - Complete Course
Angular Js Get Started - Complete Course
EPAM Systems
 
Ad

Recently uploaded (20)

Zoho Creator Solution for EI by Elsner Technologies.docx
Zoho Creator Solution for EI by Elsner Technologies.docx
Elsner Technologies Pvt. Ltd.
 
Which Hiring Management Tools Offer the Best ROI?
Which Hiring Management Tools Offer the Best ROI?
HireME
 
CodeCleaner: Mitigating Data Contamination for LLM Benchmarking
CodeCleaner: Mitigating Data Contamination for LLM Benchmarking
arabelatso
 
Folding Cheat Sheet # 9 - List Unfolding 𝑢𝑛𝑓𝑜𝑙𝑑 as the Computational Dual of ...
Folding Cheat Sheet # 9 - List Unfolding 𝑢𝑛𝑓𝑜𝑙𝑑 as the Computational Dual of ...
Philip Schwarz
 
From Data Preparation to Inference: How Alluxio Speeds Up AI
From Data Preparation to Inference: How Alluxio Speeds Up AI
Alluxio, Inc.
 
Introduction to Agile Frameworks for Product Managers.pdf
Introduction to Agile Frameworks for Product Managers.pdf
Ali Vahed
 
Y - Recursion The Hard Way GopherCon EU 2025
Y - Recursion The Hard Way GopherCon EU 2025
Eleanor McHugh
 
Download Adobe Illustrator Crack free for Windows 2025?
Download Adobe Illustrator Crack free for Windows 2025?
grete1122g
 
Simplify Task, Team, and Project Management with Orangescrum Work
Simplify Task, Team, and Project Management with Orangescrum Work
Orangescrum
 
Humans vs AI Call Agents - Qcall.ai's Special Report
Humans vs AI Call Agents - Qcall.ai's Special Report
Udit Goenka
 
Heat Treatment Process Automation in India
Heat Treatment Process Automation in India
Reckers Mechatronics
 
Top Time Tracking Solutions for Accountants
Top Time Tracking Solutions for Accountants
oliviareed320
 
Canva Pro Crack Free Download 2025-FREE LATEST
Canva Pro Crack Free Download 2025-FREE LATEST
grete1122g
 
Threat Modeling a Batch Job Framework - Teri Radichel - AWS re:Inforce 2025
Threat Modeling a Batch Job Framework - Teri Radichel - AWS re:Inforce 2025
2nd Sight Lab
 
ERP Systems in the UAE: Driving Business Transformation with Smart Solutions
ERP Systems in the UAE: Driving Business Transformation with Smart Solutions
dheeodoo
 
Best MLM Compensation Plans for Network Marketing Success in 2025
Best MLM Compensation Plans for Network Marketing Success in 2025
LETSCMS Pvt. Ltd.
 
Sysinfo OST to PST Converter Infographic
Sysinfo OST to PST Converter Infographic
SysInfo Tools
 
CodeCleaner: Mitigating Data Contamination for LLM Benchmarking
CodeCleaner: Mitigating Data Contamination for LLM Benchmarking
arabelatso
 
IDM Crack with Internet Download Manager 6.42 Build 41 [Latest 2025]
IDM Crack with Internet Download Manager 6.42 Build 41 [Latest 2025]
pcprocore
 
Streamlining CI/CD with FME Flow: A Practical Guide
Streamlining CI/CD with FME Flow: A Practical Guide
Safe Software
 
Zoho Creator Solution for EI by Elsner Technologies.docx
Zoho Creator Solution for EI by Elsner Technologies.docx
Elsner Technologies Pvt. Ltd.
 
Which Hiring Management Tools Offer the Best ROI?
Which Hiring Management Tools Offer the Best ROI?
HireME
 
CodeCleaner: Mitigating Data Contamination for LLM Benchmarking
CodeCleaner: Mitigating Data Contamination for LLM Benchmarking
arabelatso
 
Folding Cheat Sheet # 9 - List Unfolding 𝑢𝑛𝑓𝑜𝑙𝑑 as the Computational Dual of ...
Folding Cheat Sheet # 9 - List Unfolding 𝑢𝑛𝑓𝑜𝑙𝑑 as the Computational Dual of ...
Philip Schwarz
 
From Data Preparation to Inference: How Alluxio Speeds Up AI
From Data Preparation to Inference: How Alluxio Speeds Up AI
Alluxio, Inc.
 
Introduction to Agile Frameworks for Product Managers.pdf
Introduction to Agile Frameworks for Product Managers.pdf
Ali Vahed
 
Y - Recursion The Hard Way GopherCon EU 2025
Y - Recursion The Hard Way GopherCon EU 2025
Eleanor McHugh
 
Download Adobe Illustrator Crack free for Windows 2025?
Download Adobe Illustrator Crack free for Windows 2025?
grete1122g
 
Simplify Task, Team, and Project Management with Orangescrum Work
Simplify Task, Team, and Project Management with Orangescrum Work
Orangescrum
 
Humans vs AI Call Agents - Qcall.ai's Special Report
Humans vs AI Call Agents - Qcall.ai's Special Report
Udit Goenka
 
Heat Treatment Process Automation in India
Heat Treatment Process Automation in India
Reckers Mechatronics
 
Top Time Tracking Solutions for Accountants
Top Time Tracking Solutions for Accountants
oliviareed320
 
Canva Pro Crack Free Download 2025-FREE LATEST
Canva Pro Crack Free Download 2025-FREE LATEST
grete1122g
 
Threat Modeling a Batch Job Framework - Teri Radichel - AWS re:Inforce 2025
Threat Modeling a Batch Job Framework - Teri Radichel - AWS re:Inforce 2025
2nd Sight Lab
 
ERP Systems in the UAE: Driving Business Transformation with Smart Solutions
ERP Systems in the UAE: Driving Business Transformation with Smart Solutions
dheeodoo
 
Best MLM Compensation Plans for Network Marketing Success in 2025
Best MLM Compensation Plans for Network Marketing Success in 2025
LETSCMS Pvt. Ltd.
 
Sysinfo OST to PST Converter Infographic
Sysinfo OST to PST Converter Infographic
SysInfo Tools
 
CodeCleaner: Mitigating Data Contamination for LLM Benchmarking
CodeCleaner: Mitigating Data Contamination for LLM Benchmarking
arabelatso
 
IDM Crack with Internet Download Manager 6.42 Build 41 [Latest 2025]
IDM Crack with Internet Download Manager 6.42 Build 41 [Latest 2025]
pcprocore
 
Streamlining CI/CD with FME Flow: A Practical Guide
Streamlining CI/CD with FME Flow: A Practical Guide
Safe Software
 
Ad

Controllers in AngularJs

  • 2. Why Controllers? Use of Global functions is not recommended in Angularjs. Angularjs follows MVC Architecture so it expects the function to be registered with it before using the function. Writing or initializing the variable within the HTML tags is not recommended because it has to follow the MVC standards. We have to use all the angular features. EX:<div ng-app="" ng-init="myText=20">//NOT RECOMMENDED
  • 3. What are Controllers? Controllers can be defined as the code which will call different functions to get the right data from model to view. A Controller is a JavaScript Object created by JavaScript Constructor.It can be mainly used to initialization means to set the initial state of your $scope object. It can also be defined as binding data to the View and also handling the data flow into your angular application. All the business logics are handled with the controllers in the Angularjs.
  • 4. How to Use Controller? A Controller has to be always registered with the module. The ng-controller defines the application controller. Before creating a controller we have to create a module and register the controller with it. Creating a Module Var modules=angular.module(“myModule”[ ] ); It takes two parameters first one is module name and second one is the array for dependent modules.
  • 5. How to Use Controller? Creating Controller: modules.controller(“myController”,Main); Here the two parameters are “myController” is the Controller name and Main is the Method name. Example: https://codepen.io/nikhil12/pen/qjEewJ
  • 7. Thank You HAVE A GREAT DAY