SlideShare a Scribd company logo
Angular js
“What is AngularJS?”
As defined on Wikipedia:AngularJS is an open-source JavaScript framework, maintained by
Google, which assists with running single-page applications. Its goal is to augment browser-
based applications with Model–View–Controller (MVC) capability, in an effort to make both
development and testing easier.
“Why is it Called AngularJS?”
Angular means having angles or sharp corners. HTML uses angle brackets. Hence, the name!
“Why AngularJS?”
There are other Javascript frameworks like JQuery, Mootools, Dojo and Backbone.
However to choose AngularJS based on our complex web application like adding
new rows into table dynamically with copy and cut functionality with AJAX features
and also the below mentioned factors were deciding in the choice of the framework.
When NotTo Use AngularJS
AngularJS was designed with data-driven apps in mind.
AngularJS an excellent choice if your app interacts with a lot of RESTful web services.
But if your app needs heavy DOM manipulations where model data is not the
focus, instead you might choose library like jQuery, DOJO.
If you want to develop a web application, basically a game or involves heavy graphics
manipulation, AngularJS is not a good choice.
In short, AngularJS is best if your UI is datadriven.
Two Way Data Binding
Classical Template Angular Templates
What is One-Way Data Binding?
In Common every HTML attribute specific to AngularJS is called directive and has a specific
role in an AngularJS application. Here HTML page is a template and since it is not a final
version and perhaps it rendered by web browser.
The ng-app directive marks the DOM element that contains the AngularJS application.
In the below code we have initialized 2 variables through ng-init directive.
A data binding can be specified in two different ways:
with curly braces: {{expression}}
with the ng-bind directive: ng-bind= “varName”
What isTwo-Way Data Binding?
In the below example , the we have a 2-Way Data Binding, when a model variable is
bound to a HTML element that can both change and display the value of the variable.
Here ng-model directive to bind a model variable to the HTML element that can not only
display its value, but also change it.
AngularJS Expression
Angular expressions are JavaScript-like code snippets that are usually placed in bindings such as
{{expression}}
Angular Expressions vs. JavaScript Expressions
Angular expressions are like JavaScript expressions with the following differences:
Context: JavaScript expressions are evaluated against the global window. In Angular,
expressions are evaluated against a scope
Forgiving: In JavaScript, trying to evaluate undefined properties generates ReferenceError or
TypeError. In Angular, expression evaluation is forgiving to undefined and null.
No Control Flow Statements: you cannot use the following in an Angular expression:
conditionals, loops, or exceptions.
Filters: You can use filters within expressions to format data before displaying it.
Directives & Filters
What are Directives & Filters?
Directives
At a high level directives are markers on DOM element which tells HTML compiler to attach a specified
behavior to that DOM element or even transform the DOM element and its children.
Angular comes with a set of these directives built-in, like ngBind, ngModel, ngRepeat and ngView.
Filters
A filter formats the value of an expression for display to the user.They can be used in view templates,
controllers or services.
AngularJS provides some in-built filters like for search, lowercase, uppercase, orderby and groupby.
Below given an example: – Simple table with ng-repeat directive and search filter.
Angular js
Angular js
MVM
AngularJs is MVW
MVW ModelView Whatever?
AngularJS is an MVW framework (Model-View-Whatever) where Whatever means
Whatever Works for You. The reason is that AngularJS can be used both as Model-View-
Controller (MVC) and Model-View-View-Model (MVVM) framework. But what’s important
to us is that we can build solid web apps with great structure and design with minimum
effort.
To Understand more on it here the blog : http://addyosmani.com/blog/understanding-
mvvm-a-guide-for-javascript-developers/
MVC – ModelView Controller
MVC application structure was introduced in the 1970s as part of Smalltalk and now it
became one of the popular Design Pattern.
The core idea behind MVC is that we have clear separation in our code between managing
its data (model), the application logic (controller), and presenting the data to the user
(view).
Let we see that how this design pattern plays an important role in AngularJs.
In Angular applications,
Controller
A controller is a JavaScript function
• contains data
• specifies the behavior
• should contain only the business logic needed for a single view.
Scope
Scopes are a core fundamental of any Angular app. Scopes serve as the glue between the controller
and the view.
•Scope is an object that refers to the application model.
•Scopes are arranged in hierarchical structure which mimic the DOM structure of the application
•Scopes are the source of truth for the application state
Model: attrs of Scope
Dependency Injection & AJAX Support
Dependency Injection
AngularJS comes with a built-in dependency injection mechanism. Dependency Injection (DI) is a
software design pattern that deals with how components get hold of their dependencies. We can
divide our application into multiple different types of components which AngularJS can inject into
each other. Modularizing our application makes it easier to reuse and configure the components in our
application.
Let us see how we can inject the custom directive into the controller
Directive for IE 8 Select Option Issue
Dependency Injection & AJAX Support
Note: Below I have given how to inject and to use in our presentation layer
Include in your Controller and Presentation Layer
Dependency Injection & AJAX Support
Note: Below I have given how to inject and to use in our presentation layer
Include in your Controller and Presentation Layer
Scope
As we saw a Scope is glue between Model andView.
Essentially, a scope is nothing but a plain old JavaScript object, and that is just a container
for key/value pairs, as follows:
var myObject={name:'AngularJS', creator:'Misko'}
A scope—like other objects—can have properties and functions attached to it.
The only difference is that we don't usually construct a scope object manually.
Rather, AngularJS automatically creates and injects one for us.
In our example, we attached properties to the scope inside the controller:
Every AngularJS application has at least one scope called $rootScope.
$rootScope is the parent of all scopes
All the properties attached to $rootScope are implicitly available to scope 1.
Similarly, scope 2 has access to all the properties attached to scope 1.
Every JavaScript constructor function has a property called prototype which points to an
object.
When you access a property on an object (someObject.someProperty) JavaScript searches for
the property in that object. If it's found, it is returned. If not, then JavaScript starts searching
for the property in the object's prototype.
The prototype property is nothing but another object.
<div ng-app> 
<div ng-controller="OuterController">

<div ng-controller="InnerController">

</div>
</div>
</div>
function Bike(color,company){
this.color=color;
this.company=company;
}
Bike.prototype.year=2012; // Bike is a functional object, so it has the `prototype` property
var bike=new Bike ('red',‘Bajaj');
console.log(bike.color); // prints color from bike
console.log(bike.year); // prints year from Bike.prototype
console.log(bike.hasOwnProperty('year')); //returns false
Writing a Primitive to an Object
Our object bike does not have a property year, but Bike.prototype does. When you
try to read bike.year you get the value from bike.prototype. But you can also attach
the property year to bike, like this:
bike.year=2000 //sets property 'year' on bike
console.log(bike.year); // returns 'year' property from bike and NOT from bike.prototype
console.log(bike.hasOwnProperty('year')); //returns true as Bike has 'year' property
Now,When you attach a new property to an object the property is attached to it and not
the prototype. Subsequently when you access the property, JavaScript no longer
consults the prototype because the property is found right there in the object itself.
Writing a ReferenceType to an Object
Let's attach an object called data to Bike.prototype:
Bike.prototype.data={}; //set it to empty object
Now have a look at the following code:
bike.data.engine='rear'; //This does not create a new property called 'data' on bike object
console.log(bike.data.engine); //returns 'rear' and it comes from Bike.prototype
console.log(bike.hasOwnProperty('data')); // false, as bike doesn't have own property
'data‘
Bike.prototype.hasOwnProperty('data'); // 'data' property is created in prototype.
Objects Can Extend Objects
Objects can extend other objects in JavaScript, and this is the key to understanding
AngularJS scope inheritance. Have a look at the following snippet:
var honda=Object.create(bike);
console.log(Object.getPrototypeOf(honda)); //Bike {}
Object.create() creates a new object whose internal prototype property points
to the object specified as the first argument to the function. As a result the honda
object's prototype now points to bike object.Therefore, honda has all the properties
defined in the bike instance.
This a quick overview of prototypal inheritance
Prototypal Inheritance in AngularJS Scopes
The $rootScope object has a function called $new() that's used to create child
scopes. Let's consider the previous example where we nested two controllers and
had one $rootScope.The code is repeated below:
<div ng-app> 
<div ng-controller="OuterController">

<div ng-controller="InnerController">

</div>
</div>
</div>
The below diagram, taken from the AngularJS GitHub page, depicts how scopes
inherit each other.

More Related Content

What's hot

Angular js
Angular jsAngular js
Angular js
Knoldus Inc.
 
Introduction to Angularjs
Introduction to AngularjsIntroduction to Angularjs
Introduction to Angularjs
Manish Shekhawat
 
AngularJS
AngularJSAngularJS
AngularJS for Beginners
AngularJS for BeginnersAngularJS for Beginners
AngularJS for Beginners
Edureka!
 
Introduction to AngularJS Framework
Introduction to AngularJS FrameworkIntroduction to AngularJS Framework
Introduction to AngularJS Framework
Raveendra R
 
Angular Js Get Started - Complete Course
Angular Js Get Started - Complete CourseAngular Js Get Started - Complete Course
Angular Js Get Started - Complete Course
EPAM Systems
 
AngularJs presentation
AngularJs presentation AngularJs presentation
AngularJs presentation
Phan Tuan
 
Angular.js - JS Camp UKraine 2013
Angular.js - JS Camp UKraine 2013Angular.js - JS Camp UKraine 2013
Angular.js - JS Camp UKraine 2013
Max Klymyshyn
 
The Basics Angular JS
The Basics Angular JS The Basics Angular JS
The Basics Angular JS
OrisysIndia
 
Angular JS - Introduction
Angular JS - IntroductionAngular JS - Introduction
Angular JS - Introduction
Sagar Acharya
 
OCTO BOF - How to build Netvibes with AngularJS
OCTO BOF - How to build Netvibes with AngularJSOCTO BOF - How to build Netvibes with AngularJS
OCTO BOF - How to build Netvibes with AngularJS
Jonathan Meiss
 
Angular Js Advantages - Complete Reference
Angular Js Advantages - Complete ReferenceAngular Js Advantages - Complete Reference
Angular Js Advantages - Complete Reference
EPAM Systems
 
AngularJS intro
AngularJS introAngularJS intro
AngularJS intro
dizabl
 
Angular js PPT
Angular js PPTAngular js PPT
Angular js PPT
Imtiyaz Ahmad Khan
 
AngularJS Beginners Workshop
AngularJS Beginners WorkshopAngularJS Beginners Workshop
AngularJS Beginners Workshop
Sathish VJ
 
Angular js 1.3 presentation for fed nov 2014
Angular js 1.3 presentation for fed   nov 2014Angular js 1.3 presentation for fed   nov 2014
Angular js 1.3 presentation for fed nov 2014
Sarah Hudson
 
Angular js
Angular jsAngular js
Angular from Scratch
Angular from ScratchAngular from Scratch
Angular from Scratch
Christian Lilley
 
Angular JS tutorial
Angular JS tutorialAngular JS tutorial
Angular JS tutorial
cncwebworld
 
AngularJs (1.x) Presentation
AngularJs (1.x) PresentationAngularJs (1.x) Presentation
AngularJs (1.x) Presentation
Raghubir Singh
 

What's hot (20)

Angular js
Angular jsAngular js
Angular js
 
Introduction to Angularjs
Introduction to AngularjsIntroduction to Angularjs
Introduction to Angularjs
 
AngularJS
AngularJSAngularJS
AngularJS
 
AngularJS for Beginners
AngularJS for BeginnersAngularJS for Beginners
AngularJS for Beginners
 
Introduction to AngularJS Framework
Introduction to AngularJS FrameworkIntroduction to AngularJS Framework
Introduction to AngularJS Framework
 
Angular Js Get Started - Complete Course
Angular Js Get Started - Complete CourseAngular Js Get Started - Complete Course
Angular Js Get Started - Complete Course
 
AngularJs presentation
AngularJs presentation AngularJs presentation
AngularJs presentation
 
Angular.js - JS Camp UKraine 2013
Angular.js - JS Camp UKraine 2013Angular.js - JS Camp UKraine 2013
Angular.js - JS Camp UKraine 2013
 
The Basics Angular JS
The Basics Angular JS The Basics Angular JS
The Basics Angular JS
 
Angular JS - Introduction
Angular JS - IntroductionAngular JS - Introduction
Angular JS - Introduction
 
OCTO BOF - How to build Netvibes with AngularJS
OCTO BOF - How to build Netvibes with AngularJSOCTO BOF - How to build Netvibes with AngularJS
OCTO BOF - How to build Netvibes with AngularJS
 
Angular Js Advantages - Complete Reference
Angular Js Advantages - Complete ReferenceAngular Js Advantages - Complete Reference
Angular Js Advantages - Complete Reference
 
AngularJS intro
AngularJS introAngularJS intro
AngularJS intro
 
Angular js PPT
Angular js PPTAngular js PPT
Angular js PPT
 
AngularJS Beginners Workshop
AngularJS Beginners WorkshopAngularJS Beginners Workshop
AngularJS Beginners Workshop
 
Angular js 1.3 presentation for fed nov 2014
Angular js 1.3 presentation for fed   nov 2014Angular js 1.3 presentation for fed   nov 2014
Angular js 1.3 presentation for fed nov 2014
 
Angular js
Angular jsAngular js
Angular js
 
Angular from Scratch
Angular from ScratchAngular from Scratch
Angular from Scratch
 
Angular JS tutorial
Angular JS tutorialAngular JS tutorial
Angular JS tutorial
 
AngularJs (1.x) Presentation
AngularJs (1.x) PresentationAngularJs (1.x) Presentation
AngularJs (1.x) Presentation
 

Similar to Angular js

AngularJS Basics
AngularJS BasicsAngularJS Basics
AngularJS Basics
Ravi Mone
 
AngularJS By Vipin
AngularJS By VipinAngularJS By Vipin
AngularJS By Vipin
Vipin Mundayad
 
angularjs_tutorial.docx
angularjs_tutorial.docxangularjs_tutorial.docx
angularjs_tutorial.docx
telegramvip
 
Angular js
Angular jsAngular js
Angular js
Larry Ball
 
Kalp Corporate Angular Js Tutorials
Kalp Corporate Angular Js TutorialsKalp Corporate Angular Js Tutorials
Kalp Corporate Angular Js Tutorials
Kalp Corporate
 
AngularJS
AngularJSAngularJS
AngularJS
Ermir Hoxhaj
 
AngularJS in practice
AngularJS in practiceAngularJS in practice
AngularJS in practice
Eugene Fidelin
 
Angular js getting started
Angular js getting startedAngular js getting started
Angular js getting started
Hemant Mali
 
Dive into Angular, part 1: Introduction
Dive into Angular, part 1: IntroductionDive into Angular, part 1: Introduction
Dive into Angular, part 1: Introduction
Oleksii Prohonnyi
 
Training On Angular Js
Training On Angular JsTraining On Angular Js
Training On Angular Js
Mahima Radhakrishnan
 
Angular 6 Training with project in hyderabad india
Angular 6 Training with project in hyderabad indiaAngular 6 Training with project in hyderabad india
Angular 6 Training with project in hyderabad india
php2ranjan
 
Angular introduction basic
Angular introduction basicAngular introduction basic
Angular introduction basic
jagriti srivastava
 
AngularJs
AngularJsAngularJs
AngularJs
Abdhesh Kumar
 
Angularjs 131211063348-phpapp01
Angularjs 131211063348-phpapp01Angularjs 131211063348-phpapp01
Angularjs 131211063348-phpapp01
Arunangsu Sahu
 
Understanding angular js
Understanding angular jsUnderstanding angular js
Understanding angular js
Aayush Shrestha
 
AngularJS
AngularJS AngularJS
Angularjs overview
Angularjs  overviewAngularjs  overview
Angularjs overview
VickyCmd
 
AgularJS basics- angular directives and controllers
AgularJS basics- angular directives and controllersAgularJS basics- angular directives and controllers
AgularJS basics- angular directives and controllers
jobinThomas54
 
Angular js workshop
Angular js workshopAngular js workshop
Angular js workshop
Rolands Krumbergs
 
Angular Basics.pptx
Angular Basics.pptxAngular Basics.pptx
Angular Basics.pptx
AshokKumar616995
 

Similar to Angular js (20)

AngularJS Basics
AngularJS BasicsAngularJS Basics
AngularJS Basics
 
AngularJS By Vipin
AngularJS By VipinAngularJS By Vipin
AngularJS By Vipin
 
angularjs_tutorial.docx
angularjs_tutorial.docxangularjs_tutorial.docx
angularjs_tutorial.docx
 
Angular js
Angular jsAngular js
Angular js
 
Kalp Corporate Angular Js Tutorials
Kalp Corporate Angular Js TutorialsKalp Corporate Angular Js Tutorials
Kalp Corporate Angular Js Tutorials
 
AngularJS
AngularJSAngularJS
AngularJS
 
AngularJS in practice
AngularJS in practiceAngularJS in practice
AngularJS in practice
 
Angular js getting started
Angular js getting startedAngular js getting started
Angular js getting started
 
Dive into Angular, part 1: Introduction
Dive into Angular, part 1: IntroductionDive into Angular, part 1: Introduction
Dive into Angular, part 1: Introduction
 
Training On Angular Js
Training On Angular JsTraining On Angular Js
Training On Angular Js
 
Angular 6 Training with project in hyderabad india
Angular 6 Training with project in hyderabad indiaAngular 6 Training with project in hyderabad india
Angular 6 Training with project in hyderabad india
 
Angular introduction basic
Angular introduction basicAngular introduction basic
Angular introduction basic
 
AngularJs
AngularJsAngularJs
AngularJs
 
Angularjs 131211063348-phpapp01
Angularjs 131211063348-phpapp01Angularjs 131211063348-phpapp01
Angularjs 131211063348-phpapp01
 
Understanding angular js
Understanding angular jsUnderstanding angular js
Understanding angular js
 
AngularJS
AngularJS AngularJS
AngularJS
 
Angularjs overview
Angularjs  overviewAngularjs  overview
Angularjs overview
 
AgularJS basics- angular directives and controllers
AgularJS basics- angular directives and controllersAgularJS basics- angular directives and controllers
AgularJS basics- angular directives and controllers
 
Angular js workshop
Angular js workshopAngular js workshop
Angular js workshop
 
Angular Basics.pptx
Angular Basics.pptxAngular Basics.pptx
Angular Basics.pptx
 

Recently uploaded

TrustArc Webinar - 2024 Data Privacy Trends: A Mid-Year Check-In
TrustArc Webinar - 2024 Data Privacy Trends: A Mid-Year Check-InTrustArc Webinar - 2024 Data Privacy Trends: A Mid-Year Check-In
TrustArc Webinar - 2024 Data Privacy Trends: A Mid-Year Check-In
TrustArc
 
INDIAN AIR FORCE FIGHTER PLANES LIST.pdf
INDIAN AIR FORCE FIGHTER PLANES LIST.pdfINDIAN AIR FORCE FIGHTER PLANES LIST.pdf
INDIAN AIR FORCE FIGHTER PLANES LIST.pdf
jackson110191
 
Active Inference is a veryyyyyyyyyyyyyyyyyyyyyyyy
Active Inference is a veryyyyyyyyyyyyyyyyyyyyyyyyActive Inference is a veryyyyyyyyyyyyyyyyyyyyyyyy
Active Inference is a veryyyyyyyyyyyyyyyyyyyyyyyy
RaminGhanbari2
 
How to Build a Profitable IoT Product.pptx
How to Build a Profitable IoT Product.pptxHow to Build a Profitable IoT Product.pptx
How to Build a Profitable IoT Product.pptx
Adam Dunkels
 
20240702 Présentation Plateforme GenAI.pdf
20240702 Présentation Plateforme GenAI.pdf20240702 Présentation Plateforme GenAI.pdf
20240702 Présentation Plateforme GenAI.pdf
Sally Laouacheria
 
The Increasing Use of the National Research Platform by the CSU Campuses
The Increasing Use of the National Research Platform by the CSU CampusesThe Increasing Use of the National Research Platform by the CSU Campuses
The Increasing Use of the National Research Platform by the CSU Campuses
Larry Smarr
 
Quantum Communications Q&A with Gemini LLM
Quantum Communications Q&A with Gemini LLMQuantum Communications Q&A with Gemini LLM
Quantum Communications Q&A with Gemini LLM
Vijayananda Mohire
 
Coordinate Systems in FME 101 - Webinar Slides
Coordinate Systems in FME 101 - Webinar SlidesCoordinate Systems in FME 101 - Webinar Slides
Coordinate Systems in FME 101 - Webinar Slides
Safe Software
 
Scaling Connections in PostgreSQL Postgres Bangalore(PGBLR) Meetup-2 - Mydbops
Scaling Connections in PostgreSQL Postgres Bangalore(PGBLR) Meetup-2 - MydbopsScaling Connections in PostgreSQL Postgres Bangalore(PGBLR) Meetup-2 - Mydbops
Scaling Connections in PostgreSQL Postgres Bangalore(PGBLR) Meetup-2 - Mydbops
Mydbops
 
How RPA Help in the Transportation and Logistics Industry.pptx
How RPA Help in the Transportation and Logistics Industry.pptxHow RPA Help in the Transportation and Logistics Industry.pptx
How RPA Help in the Transportation and Logistics Industry.pptx
SynapseIndia
 
Fluttercon 2024: Showing that you care about security - OpenSSF Scorecards fo...
Fluttercon 2024: Showing that you care about security - OpenSSF Scorecards fo...Fluttercon 2024: Showing that you care about security - OpenSSF Scorecards fo...
Fluttercon 2024: Showing that you care about security - OpenSSF Scorecards fo...
Chris Swan
 
Calgary MuleSoft Meetup APM and IDP .pptx
Calgary MuleSoft Meetup APM and IDP .pptxCalgary MuleSoft Meetup APM and IDP .pptx
Calgary MuleSoft Meetup APM and IDP .pptx
ishalveerrandhawa1
 
WhatsApp Image 2024-03-27 at 08.19.52_bfd93109.pdf
WhatsApp Image 2024-03-27 at 08.19.52_bfd93109.pdfWhatsApp Image 2024-03-27 at 08.19.52_bfd93109.pdf
WhatsApp Image 2024-03-27 at 08.19.52_bfd93109.pdf
ArgaBisma
 
Best Programming Language for Civil Engineers
Best Programming Language for Civil EngineersBest Programming Language for Civil Engineers
Best Programming Language for Civil Engineers
Awais Yaseen
 
20240705 QFM024 Irresponsible AI Reading List June 2024
20240705 QFM024 Irresponsible AI Reading List June 202420240705 QFM024 Irresponsible AI Reading List June 2024
20240705 QFM024 Irresponsible AI Reading List June 2024
Matthew Sinclair
 
Research Directions for Cross Reality Interfaces
Research Directions for Cross Reality InterfacesResearch Directions for Cross Reality Interfaces
Research Directions for Cross Reality Interfaces
Mark Billinghurst
 
Choose our Linux Web Hosting for a seamless and successful online presence
Choose our Linux Web Hosting for a seamless and successful online presenceChoose our Linux Web Hosting for a seamless and successful online presence
Choose our Linux Web Hosting for a seamless and successful online presence
rajancomputerfbd
 
How Social Media Hackers Help You to See Your Wife's Message.pdf
How Social Media Hackers Help You to See Your Wife's Message.pdfHow Social Media Hackers Help You to See Your Wife's Message.pdf
How Social Media Hackers Help You to See Your Wife's Message.pdf
HackersList
 
Password Rotation in 2024 is still Relevant
Password Rotation in 2024 is still RelevantPassword Rotation in 2024 is still Relevant
Password Rotation in 2024 is still Relevant
Bert Blevins
 
論文紹介:A Systematic Survey of Prompt Engineering on Vision-Language Foundation ...
論文紹介:A Systematic Survey of Prompt Engineering on Vision-Language Foundation ...論文紹介:A Systematic Survey of Prompt Engineering on Vision-Language Foundation ...
論文紹介:A Systematic Survey of Prompt Engineering on Vision-Language Foundation ...
Toru Tamaki
 

Recently uploaded (20)

TrustArc Webinar - 2024 Data Privacy Trends: A Mid-Year Check-In
TrustArc Webinar - 2024 Data Privacy Trends: A Mid-Year Check-InTrustArc Webinar - 2024 Data Privacy Trends: A Mid-Year Check-In
TrustArc Webinar - 2024 Data Privacy Trends: A Mid-Year Check-In
 
INDIAN AIR FORCE FIGHTER PLANES LIST.pdf
INDIAN AIR FORCE FIGHTER PLANES LIST.pdfINDIAN AIR FORCE FIGHTER PLANES LIST.pdf
INDIAN AIR FORCE FIGHTER PLANES LIST.pdf
 
Active Inference is a veryyyyyyyyyyyyyyyyyyyyyyyy
Active Inference is a veryyyyyyyyyyyyyyyyyyyyyyyyActive Inference is a veryyyyyyyyyyyyyyyyyyyyyyyy
Active Inference is a veryyyyyyyyyyyyyyyyyyyyyyyy
 
How to Build a Profitable IoT Product.pptx
How to Build a Profitable IoT Product.pptxHow to Build a Profitable IoT Product.pptx
How to Build a Profitable IoT Product.pptx
 
20240702 Présentation Plateforme GenAI.pdf
20240702 Présentation Plateforme GenAI.pdf20240702 Présentation Plateforme GenAI.pdf
20240702 Présentation Plateforme GenAI.pdf
 
The Increasing Use of the National Research Platform by the CSU Campuses
The Increasing Use of the National Research Platform by the CSU CampusesThe Increasing Use of the National Research Platform by the CSU Campuses
The Increasing Use of the National Research Platform by the CSU Campuses
 
Quantum Communications Q&A with Gemini LLM
Quantum Communications Q&A with Gemini LLMQuantum Communications Q&A with Gemini LLM
Quantum Communications Q&A with Gemini LLM
 
Coordinate Systems in FME 101 - Webinar Slides
Coordinate Systems in FME 101 - Webinar SlidesCoordinate Systems in FME 101 - Webinar Slides
Coordinate Systems in FME 101 - Webinar Slides
 
Scaling Connections in PostgreSQL Postgres Bangalore(PGBLR) Meetup-2 - Mydbops
Scaling Connections in PostgreSQL Postgres Bangalore(PGBLR) Meetup-2 - MydbopsScaling Connections in PostgreSQL Postgres Bangalore(PGBLR) Meetup-2 - Mydbops
Scaling Connections in PostgreSQL Postgres Bangalore(PGBLR) Meetup-2 - Mydbops
 
How RPA Help in the Transportation and Logistics Industry.pptx
How RPA Help in the Transportation and Logistics Industry.pptxHow RPA Help in the Transportation and Logistics Industry.pptx
How RPA Help in the Transportation and Logistics Industry.pptx
 
Fluttercon 2024: Showing that you care about security - OpenSSF Scorecards fo...
Fluttercon 2024: Showing that you care about security - OpenSSF Scorecards fo...Fluttercon 2024: Showing that you care about security - OpenSSF Scorecards fo...
Fluttercon 2024: Showing that you care about security - OpenSSF Scorecards fo...
 
Calgary MuleSoft Meetup APM and IDP .pptx
Calgary MuleSoft Meetup APM and IDP .pptxCalgary MuleSoft Meetup APM and IDP .pptx
Calgary MuleSoft Meetup APM and IDP .pptx
 
WhatsApp Image 2024-03-27 at 08.19.52_bfd93109.pdf
WhatsApp Image 2024-03-27 at 08.19.52_bfd93109.pdfWhatsApp Image 2024-03-27 at 08.19.52_bfd93109.pdf
WhatsApp Image 2024-03-27 at 08.19.52_bfd93109.pdf
 
Best Programming Language for Civil Engineers
Best Programming Language for Civil EngineersBest Programming Language for Civil Engineers
Best Programming Language for Civil Engineers
 
20240705 QFM024 Irresponsible AI Reading List June 2024
20240705 QFM024 Irresponsible AI Reading List June 202420240705 QFM024 Irresponsible AI Reading List June 2024
20240705 QFM024 Irresponsible AI Reading List June 2024
 
Research Directions for Cross Reality Interfaces
Research Directions for Cross Reality InterfacesResearch Directions for Cross Reality Interfaces
Research Directions for Cross Reality Interfaces
 
Choose our Linux Web Hosting for a seamless and successful online presence
Choose our Linux Web Hosting for a seamless and successful online presenceChoose our Linux Web Hosting for a seamless and successful online presence
Choose our Linux Web Hosting for a seamless and successful online presence
 
How Social Media Hackers Help You to See Your Wife's Message.pdf
How Social Media Hackers Help You to See Your Wife's Message.pdfHow Social Media Hackers Help You to See Your Wife's Message.pdf
How Social Media Hackers Help You to See Your Wife's Message.pdf
 
Password Rotation in 2024 is still Relevant
Password Rotation in 2024 is still RelevantPassword Rotation in 2024 is still Relevant
Password Rotation in 2024 is still Relevant
 
論文紹介:A Systematic Survey of Prompt Engineering on Vision-Language Foundation ...
論文紹介:A Systematic Survey of Prompt Engineering on Vision-Language Foundation ...論文紹介:A Systematic Survey of Prompt Engineering on Vision-Language Foundation ...
論文紹介:A Systematic Survey of Prompt Engineering on Vision-Language Foundation ...
 

Angular js

  • 2. “What is AngularJS?” As defined on Wikipedia:AngularJS is an open-source JavaScript framework, maintained by Google, which assists with running single-page applications. Its goal is to augment browser- based applications with Model–View–Controller (MVC) capability, in an effort to make both development and testing easier. “Why is it Called AngularJS?” Angular means having angles or sharp corners. HTML uses angle brackets. Hence, the name!
  • 3. “Why AngularJS?” There are other Javascript frameworks like JQuery, Mootools, Dojo and Backbone. However to choose AngularJS based on our complex web application like adding new rows into table dynamically with copy and cut functionality with AJAX features and also the below mentioned factors were deciding in the choice of the framework.
  • 4. When NotTo Use AngularJS AngularJS was designed with data-driven apps in mind. AngularJS an excellent choice if your app interacts with a lot of RESTful web services. But if your app needs heavy DOM manipulations where model data is not the focus, instead you might choose library like jQuery, DOJO. If you want to develop a web application, basically a game or involves heavy graphics manipulation, AngularJS is not a good choice. In short, AngularJS is best if your UI is datadriven.
  • 5. Two Way Data Binding Classical Template Angular Templates What is One-Way Data Binding? In Common every HTML attribute specific to AngularJS is called directive and has a specific role in an AngularJS application. Here HTML page is a template and since it is not a final version and perhaps it rendered by web browser. The ng-app directive marks the DOM element that contains the AngularJS application. In the below code we have initialized 2 variables through ng-init directive. A data binding can be specified in two different ways: with curly braces: {{expression}} with the ng-bind directive: ng-bind= “varName”
  • 6. What isTwo-Way Data Binding? In the below example , the we have a 2-Way Data Binding, when a model variable is bound to a HTML element that can both change and display the value of the variable. Here ng-model directive to bind a model variable to the HTML element that can not only display its value, but also change it.
  • 7. AngularJS Expression Angular expressions are JavaScript-like code snippets that are usually placed in bindings such as {{expression}} Angular Expressions vs. JavaScript Expressions Angular expressions are like JavaScript expressions with the following differences: Context: JavaScript expressions are evaluated against the global window. In Angular, expressions are evaluated against a scope Forgiving: In JavaScript, trying to evaluate undefined properties generates ReferenceError or TypeError. In Angular, expression evaluation is forgiving to undefined and null. No Control Flow Statements: you cannot use the following in an Angular expression: conditionals, loops, or exceptions. Filters: You can use filters within expressions to format data before displaying it.
  • 8. Directives & Filters What are Directives & Filters? Directives At a high level directives are markers on DOM element which tells HTML compiler to attach a specified behavior to that DOM element or even transform the DOM element and its children. Angular comes with a set of these directives built-in, like ngBind, ngModel, ngRepeat and ngView. Filters A filter formats the value of an expression for display to the user.They can be used in view templates, controllers or services. AngularJS provides some in-built filters like for search, lowercase, uppercase, orderby and groupby. Below given an example: – Simple table with ng-repeat directive and search filter.
  • 11. MVM AngularJs is MVW MVW ModelView Whatever? AngularJS is an MVW framework (Model-View-Whatever) where Whatever means Whatever Works for You. The reason is that AngularJS can be used both as Model-View- Controller (MVC) and Model-View-View-Model (MVVM) framework. But what’s important to us is that we can build solid web apps with great structure and design with minimum effort. To Understand more on it here the blog : http://addyosmani.com/blog/understanding- mvvm-a-guide-for-javascript-developers/
  • 12. MVC – ModelView Controller MVC application structure was introduced in the 1970s as part of Smalltalk and now it became one of the popular Design Pattern. The core idea behind MVC is that we have clear separation in our code between managing its data (model), the application logic (controller), and presenting the data to the user (view). Let we see that how this design pattern plays an important role in AngularJs. In Angular applications,
  • 13. Controller A controller is a JavaScript function • contains data • specifies the behavior • should contain only the business logic needed for a single view.
  • 14. Scope Scopes are a core fundamental of any Angular app. Scopes serve as the glue between the controller and the view. •Scope is an object that refers to the application model. •Scopes are arranged in hierarchical structure which mimic the DOM structure of the application •Scopes are the source of truth for the application state
  • 16. Dependency Injection & AJAX Support Dependency Injection AngularJS comes with a built-in dependency injection mechanism. Dependency Injection (DI) is a software design pattern that deals with how components get hold of their dependencies. We can divide our application into multiple different types of components which AngularJS can inject into each other. Modularizing our application makes it easier to reuse and configure the components in our application. Let us see how we can inject the custom directive into the controller Directive for IE 8 Select Option Issue
  • 17. Dependency Injection & AJAX Support Note: Below I have given how to inject and to use in our presentation layer Include in your Controller and Presentation Layer
  • 18. Dependency Injection & AJAX Support Note: Below I have given how to inject and to use in our presentation layer Include in your Controller and Presentation Layer
  • 19. Scope As we saw a Scope is glue between Model andView. Essentially, a scope is nothing but a plain old JavaScript object, and that is just a container for key/value pairs, as follows: var myObject={name:'AngularJS', creator:'Misko'} A scope—like other objects—can have properties and functions attached to it. The only difference is that we don't usually construct a scope object manually. Rather, AngularJS automatically creates and injects one for us. In our example, we attached properties to the scope inside the controller:
  • 20. Every AngularJS application has at least one scope called $rootScope. $rootScope is the parent of all scopes All the properties attached to $rootScope are implicitly available to scope 1. Similarly, scope 2 has access to all the properties attached to scope 1. Every JavaScript constructor function has a property called prototype which points to an object. When you access a property on an object (someObject.someProperty) JavaScript searches for the property in that object. If it's found, it is returned. If not, then JavaScript starts searching for the property in the object's prototype. The prototype property is nothing but another object. <div ng-app> <!-- creates a $rootScope --> <div ng-controller="OuterController"> <!--creates a scope (call it scope 1) that inherits from $rootScope--> <div ng-controller="InnerController"> <!-- Creates a child scope (call it scope 2) that inherits from scope 1 --> </div> </div> </div>
  • 21. function Bike(color,company){ this.color=color; this.company=company; } Bike.prototype.year=2012; // Bike is a functional object, so it has the `prototype` property var bike=new Bike ('red',‘Bajaj'); console.log(bike.color); // prints color from bike console.log(bike.year); // prints year from Bike.prototype console.log(bike.hasOwnProperty('year')); //returns false
  • 22. Writing a Primitive to an Object Our object bike does not have a property year, but Bike.prototype does. When you try to read bike.year you get the value from bike.prototype. But you can also attach the property year to bike, like this: bike.year=2000 //sets property 'year' on bike console.log(bike.year); // returns 'year' property from bike and NOT from bike.prototype console.log(bike.hasOwnProperty('year')); //returns true as Bike has 'year' property Now,When you attach a new property to an object the property is attached to it and not the prototype. Subsequently when you access the property, JavaScript no longer consults the prototype because the property is found right there in the object itself.
  • 23. Writing a ReferenceType to an Object Let's attach an object called data to Bike.prototype: Bike.prototype.data={}; //set it to empty object Now have a look at the following code: bike.data.engine='rear'; //This does not create a new property called 'data' on bike object console.log(bike.data.engine); //returns 'rear' and it comes from Bike.prototype console.log(bike.hasOwnProperty('data')); // false, as bike doesn't have own property 'data‘ Bike.prototype.hasOwnProperty('data'); // 'data' property is created in prototype.
  • 24. Objects Can Extend Objects Objects can extend other objects in JavaScript, and this is the key to understanding AngularJS scope inheritance. Have a look at the following snippet: var honda=Object.create(bike); console.log(Object.getPrototypeOf(honda)); //Bike {} Object.create() creates a new object whose internal prototype property points to the object specified as the first argument to the function. As a result the honda object's prototype now points to bike object.Therefore, honda has all the properties defined in the bike instance. This a quick overview of prototypal inheritance
  • 25. Prototypal Inheritance in AngularJS Scopes The $rootScope object has a function called $new() that's used to create child scopes. Let's consider the previous example where we nested two controllers and had one $rootScope.The code is repeated below: <div ng-app> <!-- creates a $rootScope --> <div ng-controller="OuterController"> <!--creates a scope (call it scope 1) that inherits from $rootScope--> <div ng-controller="InnerController"> <!-- Creates a child scope (call it scope 2) that inherits from scope 1 --> </div> </div> </div>
  • 26. The below diagram, taken from the AngularJS GitHub page, depicts how scopes inherit each other.