際際滷

際際滷Share a Scribd company logo
A Different Thought
AngularJS Part-2
Agenda
Agenda
1. MVVM
Agenda
1. MVVM
2. Directive
Agenda
1. MVVM
2. Directive
a. ng-show/ng-hide
Agenda
1. MVVM
2. Directive
a. ng-show/ng-hide
b. ng-click
Agenda
1. MVVM
2. Directive
a. ng-show/ng-hide
b. ng-click
c. ng-repeat
Agenda
1. MVVM
2. Directive
a. ng-show/ng-hide
b. ng-click
c. ng-repeat
3. To Do App
About Me
Amit Thakkar
Tech Blogger @ CodeChutney.in
JavaScript Lover
Working on MEAN Stack
Twitter: @amit_thakkar01
LinkedIn: linkedin.com/in/amitthakkar01
Facebook: facebook.com/amit.thakkar01
MVVM
MVVM - Controller & Model
(function (ng) {
// Defining Module
var mvvmTest = ng.module("mvvmTest", []);
// Defining Controllers
mvvmTest.controller("UserController", function () {
// defining Model
var userController = this;
userController.user = {
name: "Amit Thakkar",
age: 26
};
});
})(angular);
MVVM - Controller & Model
(function (ng) {
// Defining Module
var mvvmTest = ng.module("mvvmTest", []);
// Defining Controllers
mvvmTest.controller("UserController", function () {
// defining Model
var userController = this;
userController.user = {
name: "Amit Thakkar",
age: 26
};
});
})(angular);
MVVM - Controller & Model
(function (ng) {
// Defining Module
var mvvmTest = ng.module("mvvmTest", []);
// Defining Controllers
mvvmTest.controller("UserController", function () {
// defining Model
var userController = this;
userController.user = {
name: "Amit Thakkar",
age: 26
};
});
})(angular);
MVVM - Controller & Model
(function (ng) {
// Defining Module
var mvvmTest = ng.module("mvvmTest", []);
// Defining Controllers
mvvmTest.controller("UserController", function () {
// defining Model
var userController = this;
userController.user = {
name: "Amit Thakkar",
age: 26
};
});
})(angular);
MVVM - View
<!-- Using module -->
<html ng-app="mvvmTest">
<head lang="en">
<title>AngularJS MVVM</title>
</head>
<body>
<!-- Defining View -->
<div ng-controller="UserController as userController">
<h3>User Details:</h3>
Name: {{ userController.user.name }} <br/>
Age: {{ userController.user.age }} <br/>
</div>
</body>
</html>
MVVM - View
<!-- Using module -->
<html ng-app="mvvmTest">
<head lang="en">
<title>AngularJS MVVM</title>
</head>
<body>
<!-- Defining View -->
<div ng-controller="UserController as userController">
<h3>User Details:</h3>
Name: {{ userController.user.name }} <br/>
Age: {{ userController.user.age }} <br/>
</div>
</body>
</html>
MVVM - View
<!-- Using module -->
<html ng-app="mvvmTest">
<head lang="en">
<title>AngularJS MVVM</title>
</head>
<body>
<!-- Defining View -->
<div ng-controller="UserController as userController">
<h3>User Details:</h3>
Name: {{ userController.user.name }} <br/>
Age: {{ userController.user.age }} <br/>
</div>
</body>
</html>
MVVM - View
<!-- Using module -->
<html ng-app="mvvmTest">
<head lang="en">
<title>AngularJS MVVM</title>
</head>
<body>
<!-- Defining View -->
<div ng-controller="UserController as userController">
<h3>User Details:</h3>
Name: {{ userController.user.name }} <br/>
Age: {{ userController.user.age }} <br/>
</div>
</body>
</html>
You can checkout Demo form:
https://github.com/AmitThakkar/A-Different-Thought-AngualarJS
What is Directive?
Directive is a marker on DOM element, which tells
AngularJS to bind a specified behavior to the DOM
element and its children element.
What is Directive?ng-show/ng-hide
<h4 ng-show="todo.tasks.length">TODO List:</h4>
<h4 ng-hide="!todo.tasks.length">TODO List:</h4>
<h4 ng-show="todo.tasks.length > 0">TODO List:</h4>
<h4 ng-hide="todo.tasks.length < 1">TODO List:</h4>
What is Directive?ng-click
<input type="button" value="Remove" ng-click="todo.removeTask($index)">
What is Directive?ng-repeat
<ul>
<li ng-repeat="task in todo.tasks">
{{task}}
</li>
</ul>
TODO App ?
You can checkout Demo form:
https://github.com/AmitThakkar/A-Different-Thought-AngualarJS
Questions??
References:
MVC and MVVM with AngularJS
Ad

Recommended

Prezentacja z Angularra EU
Prezentacja z Angularra EU
Jack Refren
Todo app Angular
Todo app Angular
Bruno Alencar
Introduction to Samsung Gear SDK
Introduction to Samsung Gear SDK
Manikantan Krishnamurthy
Aalifassura 170209203254
Aalifassura 170209203254
Aztexain
Phonegap cordova selecting multiple photos
Phonegap cordova selecting multiple photos
FindNerd
SPTechCon Boston 2015 - Whither SPServices?
SPTechCon Boston 2015 - Whither SPServices?
Marc D Anderson
Performance monitoring measurement angualrjs single page apps with phantomas
Performance monitoring measurement angualrjs single page apps with phantomas
David Amend
Transakcyjno w django
Transakcyjno w django
Marcin Baran
intro to Angular js
intro to Angular js
Brian Atkins
Palestra "Do PHP ao Rails" - FOCAI
Palestra "Do PHP ao Rails" - FOCAI
Almir Mendes
Mmpng
Mmpng
Laurie Lyon, MSCS
Wiidget
Wiidget
Nurul CUP
Angular JS Basics.
Angular JS Basics.
Tharindu Prabhath Ranathunga
Web components
Web components
Revath S Kumar
Learning AngularJS - Complete coverage of AngularJS features and concepts
Learning AngularJS - Complete coverage of AngularJS features and concepts
Suresh Patidar
AngularJS 101 - Everything you need to know to get started
AngularJS 101 - Everything you need to know to get started
St辿phane B辿gaudeau
Introduction to Angularjs
Introduction to Angularjs
Manish Shekhawat
Introduction to Angularjs : kishan kumar
Introduction to Angularjs : kishan kumar
Appfinz Technologies
Best Angularjs tutorial for beginners - TIB Academy
Best Angularjs tutorial for beginners - TIB Academy
TIB Academy
Introduction to single page application with angular js
Introduction to single page application with angular js
Mindfire Solutions
AngularJS for Web and Mobile
AngularJS for Web and Mobile
Rocket Software
Get AngularJS Started!
Get AngularJS Started!
Dzmitry Ivashutsin
Client Side MVC & Angular
Client Side MVC & Angular
Alexe Bogdan
Angular JS deep dive
Angular JS deep dive
Axilis
Getting started with angular js
Getting started with angular js
Maurice De Beijer [MVP]
AngularJS.part1
AngularJS.part1
Andrey Kolodnitsky
AgularJS basics- angular directives and controllers
AgularJS basics- angular directives and controllers
jobinThomas54
Building Better Web Apps with Angular.js (SXSW 2014)
Building Better Web Apps with Angular.js (SXSW 2014)
kbekessy
AngularJS.pptx
AngularJS.pptx
ssusera120f8
Introduction to Angular Js
Introduction to Angular Js
Professional Guru

More Related Content

What's hot (6)

intro to Angular js
intro to Angular js
Brian Atkins
Palestra "Do PHP ao Rails" - FOCAI
Palestra "Do PHP ao Rails" - FOCAI
Almir Mendes
Mmpng
Mmpng
Laurie Lyon, MSCS
Wiidget
Wiidget
Nurul CUP
Angular JS Basics.
Angular JS Basics.
Tharindu Prabhath Ranathunga
Web components
Web components
Revath S Kumar

Similar to A different thought angular js part-2 (20)

Learning AngularJS - Complete coverage of AngularJS features and concepts
Learning AngularJS - Complete coverage of AngularJS features and concepts
Suresh Patidar
AngularJS 101 - Everything you need to know to get started
AngularJS 101 - Everything you need to know to get started
St辿phane B辿gaudeau
Introduction to Angularjs
Introduction to Angularjs
Manish Shekhawat
Introduction to Angularjs : kishan kumar
Introduction to Angularjs : kishan kumar
Appfinz Technologies
Best Angularjs tutorial for beginners - TIB Academy
Best Angularjs tutorial for beginners - TIB Academy
TIB Academy
Introduction to single page application with angular js
Introduction to single page application with angular js
Mindfire Solutions
AngularJS for Web and Mobile
AngularJS for Web and Mobile
Rocket Software
Get AngularJS Started!
Get AngularJS Started!
Dzmitry Ivashutsin
Client Side MVC & Angular
Client Side MVC & Angular
Alexe Bogdan
Angular JS deep dive
Angular JS deep dive
Axilis
Getting started with angular js
Getting started with angular js
Maurice De Beijer [MVP]
AngularJS.part1
AngularJS.part1
Andrey Kolodnitsky
AgularJS basics- angular directives and controllers
AgularJS basics- angular directives and controllers
jobinThomas54
Building Better Web Apps with Angular.js (SXSW 2014)
Building Better Web Apps with Angular.js (SXSW 2014)
kbekessy
AngularJS.pptx
AngularJS.pptx
ssusera120f8
Introduction to Angular Js
Introduction to Angular Js
Professional Guru
Angular workshop - Full Development Guide
Angular workshop - Full Development Guide
Nitin Giri
AngularJS Workshop
AngularJS Workshop
Gianluca Cacace
Angular js
Angular js
Manav Prasad
Angular.js Primer in Aalto University
Angular.js Primer in Aalto University
SC5.io
Learning AngularJS - Complete coverage of AngularJS features and concepts
Learning AngularJS - Complete coverage of AngularJS features and concepts
Suresh Patidar
AngularJS 101 - Everything you need to know to get started
AngularJS 101 - Everything you need to know to get started
St辿phane B辿gaudeau
Introduction to Angularjs
Introduction to Angularjs
Manish Shekhawat
Introduction to Angularjs : kishan kumar
Introduction to Angularjs : kishan kumar
Appfinz Technologies
Best Angularjs tutorial for beginners - TIB Academy
Best Angularjs tutorial for beginners - TIB Academy
TIB Academy
Introduction to single page application with angular js
Introduction to single page application with angular js
Mindfire Solutions
AngularJS for Web and Mobile
AngularJS for Web and Mobile
Rocket Software
Client Side MVC & Angular
Client Side MVC & Angular
Alexe Bogdan
Angular JS deep dive
Angular JS deep dive
Axilis
AgularJS basics- angular directives and controllers
AgularJS basics- angular directives and controllers
jobinThomas54
Building Better Web Apps with Angular.js (SXSW 2014)
Building Better Web Apps with Angular.js (SXSW 2014)
kbekessy
Introduction to Angular Js
Introduction to Angular Js
Professional Guru
Angular workshop - Full Development Guide
Angular workshop - Full Development Guide
Nitin Giri
Angular.js Primer in Aalto University
Angular.js Primer in Aalto University
SC5.io
Ad

More from Amit Thakkar (10)

Packer
Packer
Amit Thakkar
Packer
Packer
Amit Thakkar
AWS Cloud Formation
AWS Cloud Formation
Amit Thakkar
Introduction to node js
Introduction to node js
Amit Thakkar
Java script at backend nodejs
Java script at backend nodejs
Amit Thakkar
A different thought angular js part-3
A different thought angular js part-3
Amit Thakkar
A different thought AngularJS
A different thought AngularJS
Amit Thakkar
Building user interface with react
Building user interface with react
Amit Thakkar
Get expertise with mongo db
Get expertise with mongo db
Amit Thakkar
Design pattern in an expressive language java script
Design pattern in an expressive language java script
Amit Thakkar
AWS Cloud Formation
AWS Cloud Formation
Amit Thakkar
Introduction to node js
Introduction to node js
Amit Thakkar
Java script at backend nodejs
Java script at backend nodejs
Amit Thakkar
A different thought angular js part-3
A different thought angular js part-3
Amit Thakkar
A different thought AngularJS
A different thought AngularJS
Amit Thakkar
Building user interface with react
Building user interface with react
Amit Thakkar
Get expertise with mongo db
Get expertise with mongo db
Amit Thakkar
Design pattern in an expressive language java script
Design pattern in an expressive language java script
Amit Thakkar
Ad

Recently uploaded (20)

Wenn alles versagt - IBM Tape sch端tzt, was z辰hlt! Und besonders mit dem neust...
Wenn alles versagt - IBM Tape sch端tzt, was z辰hlt! Und besonders mit dem neust...
Josef Weingand
cnc-processing-centers-centateq-p-110-en.pdf
cnc-processing-centers-centateq-p-110-en.pdf
AmirStern2
Mastering AI Workflows with FME by Mark Doring
Mastering AI Workflows with FME by Mark Doring
Safe Software
OpenPOWER Foundation & Open-Source Core Innovations
OpenPOWER Foundation & Open-Source Core Innovations
IBM
"Scaling in space and time with Temporal", Andriy Lupa.pdf
"Scaling in space and time with Temporal", Andriy Lupa.pdf
Fwdays
Using the SQLExecutor for Data Quality Management: aka One man's love for the...
Using the SQLExecutor for Data Quality Management: aka One man's love for the...
Safe Software
Smarter Aviation Data Management: Lessons from Swedavia Airports and Sweco
Smarter Aviation Data Management: Lessons from Swedavia Airports and Sweco
Safe Software
" How to survive with 1 billion vectors and not sell a kidney: our low-cost c...
" How to survive with 1 billion vectors and not sell a kidney: our low-cost c...
Fwdays
WebdriverIO & JavaScript: The Perfect Duo for Web Automation
WebdriverIO & JavaScript: The Perfect Duo for Web Automation
digitaljignect
AI Agents and FME: A How-to Guide on Generating Synthetic Metadata
AI Agents and FME: A How-to Guide on Generating Synthetic Metadata
Safe Software
GenAI Opportunities and Challenges - Where 370 Enterprises Are Focusing Now.pdf
GenAI Opportunities and Challenges - Where 370 Enterprises Are Focusing Now.pdf
Priyanka Aash
A Constitutional Quagmire - Ethical Minefields of AI, Cyber, and Privacy.pdf
A Constitutional Quagmire - Ethical Minefields of AI, Cyber, and Privacy.pdf
Priyanka Aash
Coordinated Disclosure for ML - What's Different and What's the Same.pdf
Coordinated Disclosure for ML - What's Different and What's the Same.pdf
Priyanka Aash
Daily Lesson Log MATATAG ICT TEchnology 8
Daily Lesson Log MATATAG ICT TEchnology 8
LOIDAALMAZAN3
The Future of Technology: 2025-2125 by Saikat Basu.pdf
The Future of Technology: 2025-2125 by Saikat Basu.pdf
Saikat Basu
Quantum AI Discoveries: Fractal Patterns Consciousness and Cyclical Universes
Quantum AI Discoveries: Fractal Patterns Consciousness and Cyclical Universes
Saikat Basu
"Database isolation: how we deal with hundreds of direct connections to the d...
"Database isolation: how we deal with hundreds of direct connections to the d...
Fwdays
Quantum AI: Where Impossible Becomes Probable
Quantum AI: Where Impossible Becomes Probable
Saikat Basu
Python Conference Singapore - 19 Jun 2025
Python Conference Singapore - 19 Jun 2025
ninefyi
OWASP Barcelona 2025 Threat Model Library
OWASP Barcelona 2025 Threat Model Library
PetraVukmirovic
Wenn alles versagt - IBM Tape sch端tzt, was z辰hlt! Und besonders mit dem neust...
Wenn alles versagt - IBM Tape sch端tzt, was z辰hlt! Und besonders mit dem neust...
Josef Weingand
cnc-processing-centers-centateq-p-110-en.pdf
cnc-processing-centers-centateq-p-110-en.pdf
AmirStern2
Mastering AI Workflows with FME by Mark Doring
Mastering AI Workflows with FME by Mark Doring
Safe Software
OpenPOWER Foundation & Open-Source Core Innovations
OpenPOWER Foundation & Open-Source Core Innovations
IBM
"Scaling in space and time with Temporal", Andriy Lupa.pdf
"Scaling in space and time with Temporal", Andriy Lupa.pdf
Fwdays
Using the SQLExecutor for Data Quality Management: aka One man's love for the...
Using the SQLExecutor for Data Quality Management: aka One man's love for the...
Safe Software
Smarter Aviation Data Management: Lessons from Swedavia Airports and Sweco
Smarter Aviation Data Management: Lessons from Swedavia Airports and Sweco
Safe Software
" How to survive with 1 billion vectors and not sell a kidney: our low-cost c...
" How to survive with 1 billion vectors and not sell a kidney: our low-cost c...
Fwdays
WebdriverIO & JavaScript: The Perfect Duo for Web Automation
WebdriverIO & JavaScript: The Perfect Duo for Web Automation
digitaljignect
AI Agents and FME: A How-to Guide on Generating Synthetic Metadata
AI Agents and FME: A How-to Guide on Generating Synthetic Metadata
Safe Software
GenAI Opportunities and Challenges - Where 370 Enterprises Are Focusing Now.pdf
GenAI Opportunities and Challenges - Where 370 Enterprises Are Focusing Now.pdf
Priyanka Aash
A Constitutional Quagmire - Ethical Minefields of AI, Cyber, and Privacy.pdf
A Constitutional Quagmire - Ethical Minefields of AI, Cyber, and Privacy.pdf
Priyanka Aash
Coordinated Disclosure for ML - What's Different and What's the Same.pdf
Coordinated Disclosure for ML - What's Different and What's the Same.pdf
Priyanka Aash
Daily Lesson Log MATATAG ICT TEchnology 8
Daily Lesson Log MATATAG ICT TEchnology 8
LOIDAALMAZAN3
The Future of Technology: 2025-2125 by Saikat Basu.pdf
The Future of Technology: 2025-2125 by Saikat Basu.pdf
Saikat Basu
Quantum AI Discoveries: Fractal Patterns Consciousness and Cyclical Universes
Quantum AI Discoveries: Fractal Patterns Consciousness and Cyclical Universes
Saikat Basu
"Database isolation: how we deal with hundreds of direct connections to the d...
"Database isolation: how we deal with hundreds of direct connections to the d...
Fwdays
Quantum AI: Where Impossible Becomes Probable
Quantum AI: Where Impossible Becomes Probable
Saikat Basu
Python Conference Singapore - 19 Jun 2025
Python Conference Singapore - 19 Jun 2025
ninefyi
OWASP Barcelona 2025 Threat Model Library
OWASP Barcelona 2025 Threat Model Library
PetraVukmirovic

A different thought angular js part-2

  • 6. Agenda 1. MVVM 2. Directive a. ng-show/ng-hide b. ng-click
  • 7. Agenda 1. MVVM 2. Directive a. ng-show/ng-hide b. ng-click c. ng-repeat
  • 8. Agenda 1. MVVM 2. Directive a. ng-show/ng-hide b. ng-click c. ng-repeat 3. To Do App
  • 9. About Me Amit Thakkar Tech Blogger @ CodeChutney.in JavaScript Lover Working on MEAN Stack Twitter: @amit_thakkar01 LinkedIn: linkedin.com/in/amitthakkar01 Facebook: facebook.com/amit.thakkar01
  • 10. MVVM
  • 11. MVVM - Controller & Model (function (ng) { // Defining Module var mvvmTest = ng.module("mvvmTest", []); // Defining Controllers mvvmTest.controller("UserController", function () { // defining Model var userController = this; userController.user = { name: "Amit Thakkar", age: 26 }; }); })(angular);
  • 12. MVVM - Controller & Model (function (ng) { // Defining Module var mvvmTest = ng.module("mvvmTest", []); // Defining Controllers mvvmTest.controller("UserController", function () { // defining Model var userController = this; userController.user = { name: "Amit Thakkar", age: 26 }; }); })(angular);
  • 13. MVVM - Controller & Model (function (ng) { // Defining Module var mvvmTest = ng.module("mvvmTest", []); // Defining Controllers mvvmTest.controller("UserController", function () { // defining Model var userController = this; userController.user = { name: "Amit Thakkar", age: 26 }; }); })(angular);
  • 14. MVVM - Controller & Model (function (ng) { // Defining Module var mvvmTest = ng.module("mvvmTest", []); // Defining Controllers mvvmTest.controller("UserController", function () { // defining Model var userController = this; userController.user = { name: "Amit Thakkar", age: 26 }; }); })(angular);
  • 15. MVVM - View <!-- Using module --> <html ng-app="mvvmTest"> <head lang="en"> <title>AngularJS MVVM</title> </head> <body> <!-- Defining View --> <div ng-controller="UserController as userController"> <h3>User Details:</h3> Name: {{ userController.user.name }} <br/> Age: {{ userController.user.age }} <br/> </div> </body> </html>
  • 16. MVVM - View <!-- Using module --> <html ng-app="mvvmTest"> <head lang="en"> <title>AngularJS MVVM</title> </head> <body> <!-- Defining View --> <div ng-controller="UserController as userController"> <h3>User Details:</h3> Name: {{ userController.user.name }} <br/> Age: {{ userController.user.age }} <br/> </div> </body> </html>
  • 17. MVVM - View <!-- Using module --> <html ng-app="mvvmTest"> <head lang="en"> <title>AngularJS MVVM</title> </head> <body> <!-- Defining View --> <div ng-controller="UserController as userController"> <h3>User Details:</h3> Name: {{ userController.user.name }} <br/> Age: {{ userController.user.age }} <br/> </div> </body> </html>
  • 18. MVVM - View <!-- Using module --> <html ng-app="mvvmTest"> <head lang="en"> <title>AngularJS MVVM</title> </head> <body> <!-- Defining View --> <div ng-controller="UserController as userController"> <h3>User Details:</h3> Name: {{ userController.user.name }} <br/> Age: {{ userController.user.age }} <br/> </div> </body> </html>
  • 19. You can checkout Demo form: https://github.com/AmitThakkar/A-Different-Thought-AngualarJS
  • 20. What is Directive? Directive is a marker on DOM element, which tells AngularJS to bind a specified behavior to the DOM element and its children element.
  • 21. What is Directive?ng-show/ng-hide <h4 ng-show="todo.tasks.length">TODO List:</h4> <h4 ng-hide="!todo.tasks.length">TODO List:</h4> <h4 ng-show="todo.tasks.length > 0">TODO List:</h4> <h4 ng-hide="todo.tasks.length < 1">TODO List:</h4>
  • 22. What is Directive?ng-click <input type="button" value="Remove" ng-click="todo.removeTask($index)">
  • 23. What is Directive?ng-repeat <ul> <li ng-repeat="task in todo.tasks"> {{task}} </li> </ul>
  • 24. TODO App ? You can checkout Demo form: https://github.com/AmitThakkar/A-Different-Thought-AngualarJS
  • 26. References: MVC and MVVM with AngularJS