SlideShare a Scribd company logo
1 of 26
“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.
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> <!-- 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>
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> <!-- 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>
The below diagram, taken from the AngularJS GitHub page, depicts how scopes
inherit each other.

More Related Content

What's hot

Introduction to Angularjs
Introduction to AngularjsIntroduction to Angularjs
Introduction to AngularjsManish Shekhawat
 
AngularJS for Beginners
AngularJS for BeginnersAngularJS for Beginners
AngularJS for BeginnersEdureka!
 
Introduction to AngularJS Framework
Introduction to AngularJS FrameworkIntroduction to AngularJS Framework
Introduction to AngularJS FrameworkRaveendra R
 
Angular Js Get Started - Complete Course
Angular Js Get Started - Complete CourseAngular Js Get Started - Complete Course
Angular Js Get Started - Complete CourseEPAM 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 2013Max 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 - IntroductionSagar 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 AngularJSJonathan Meiss
 
Angular Js Advantages - Complete Reference
Angular Js Advantages - Complete ReferenceAngular Js Advantages - Complete Reference
Angular Js Advantages - Complete ReferenceEPAM Systems
 
AngularJS intro
AngularJS introAngularJS intro
AngularJS introdizabl
 
AngularJS Beginners Workshop
AngularJS Beginners WorkshopAngularJS Beginners Workshop
AngularJS Beginners WorkshopSathish 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 2014Sarah Hudson
 
Angular from Scratch
Angular from ScratchAngular from Scratch
Angular from ScratchChristian Lilley
 
Angular JS tutorial
Angular JS tutorialAngular JS tutorial
Angular JS tutorialcncwebworld
 
AngularJs (1.x) Presentation
AngularJs (1.x) PresentationAngularJs (1.x) Presentation
AngularJs (1.x) PresentationRaghubir 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 BasicsRavi Mone
 
AngularJS By Vipin
AngularJS By VipinAngularJS By Vipin
AngularJS By VipinVipin Mundayad
 
angularjs_tutorial.docx
angularjs_tutorial.docxangularjs_tutorial.docx
angularjs_tutorial.docxtelegramvip
 
Angular js
Angular jsAngular js
Angular jsLarry Ball
 
Kalp Corporate Angular Js Tutorials
Kalp Corporate Angular Js TutorialsKalp Corporate Angular Js Tutorials
Kalp Corporate Angular Js TutorialsKalp Corporate
 
AngularJS in practice
AngularJS in practiceAngularJS in practice
AngularJS in practiceEugene Fidelin
 
Angular js getting started
Angular js getting startedAngular js getting started
Angular js getting startedHemant Mali
 
Dive into Angular, part 1: Introduction
Dive into Angular, part 1: IntroductionDive into Angular, part 1: Introduction
Dive into Angular, part 1: IntroductionOleksii Prohonnyi
 
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 indiaphp2ranjan
 
Angular introduction basic
Angular introduction basicAngular introduction basic
Angular introduction basicjagriti srivastava
 
Angularjs 131211063348-phpapp01
Angularjs 131211063348-phpapp01Angularjs 131211063348-phpapp01
Angularjs 131211063348-phpapp01Arunangsu Sahu
 
Understanding angular js
Understanding angular jsUnderstanding angular js
Understanding angular jsAayush Shrestha
 
Angularjs overview
Angularjs  overviewAngularjs  overview
Angularjs overviewVickyCmd
 
Angular workshop - Full Development Guide
Angular workshop - Full Development GuideAngular workshop - Full Development Guide
Angular workshop - Full Development GuideNitin Giri
 

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
 
Angular js workshop
Angular js workshopAngular js workshop
Angular js workshop
 
Angular Basics.pptx
Angular Basics.pptxAngular Basics.pptx
Angular Basics.pptx
 
Angular workshop - Full Development Guide
Angular workshop - Full Development GuideAngular workshop - Full Development Guide
Angular workshop - Full Development Guide
 

Recently uploaded

FULL ENJOY 🔝 8264348440 🔝 Call Girls in Diplomatic Enclave | Delhi
FULL ENJOY 🔝 8264348440 🔝 Call Girls in Diplomatic Enclave | DelhiFULL ENJOY 🔝 8264348440 🔝 Call Girls in Diplomatic Enclave | Delhi
FULL ENJOY 🔝 8264348440 🔝 Call Girls in Diplomatic Enclave | Delhisoniya singh
 
IAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI SolutionsIAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI SolutionsEnterprise Knowledge
 
How to Remove Document Management Hurdles with X-Docs?
How to Remove Document Management Hurdles with X-Docs?How to Remove Document Management Hurdles with X-Docs?
How to Remove Document Management Hurdles with X-Docs?XfilesPro
 
Azure Monitor & Application Insight to monitor Infrastructure & Application
Azure Monitor & Application Insight to monitor Infrastructure & ApplicationAzure Monitor & Application Insight to monitor Infrastructure & Application
Azure Monitor & Application Insight to monitor Infrastructure & ApplicationAndikSusilo4
 
Presentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreterPresentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreternaman860154
 
CloudStudio User manual (basic edition):
CloudStudio User manual (basic edition):CloudStudio User manual (basic edition):
CloudStudio User manual (basic edition):comworks
 
Injustice - Developers Among Us (SciFiDevCon 2024)
Injustice - Developers Among Us (SciFiDevCon 2024)Injustice - Developers Among Us (SciFiDevCon 2024)
Injustice - Developers Among Us (SciFiDevCon 2024)Allon Mureinik
 
Benefits Of Flutter Compared To Other Frameworks
Benefits Of Flutter Compared To Other FrameworksBenefits Of Flutter Compared To Other Frameworks
Benefits Of Flutter Compared To Other FrameworksSoftradix Technologies
 
The Codex of Business Writing Software for Real-World Solutions 2.pptx
The Codex of Business Writing Software for Real-World Solutions 2.pptxThe Codex of Business Writing Software for Real-World Solutions 2.pptx
The Codex of Business Writing Software for Real-World Solutions 2.pptxMalak Abu Hammad
 
SQL Database Design For Developers at php[tek] 2024
SQL Database Design For Developers at php[tek] 2024SQL Database Design For Developers at php[tek] 2024
SQL Database Design For Developers at php[tek] 2024Scott Keck-Warren
 
Integration and Automation in Practice: CI/CD in Mule Integration and Automat...
Integration and Automation in Practice: CI/CD in Mule Integration and Automat...Integration and Automation in Practice: CI/CD in Mule Integration and Automat...
Integration and Automation in Practice: CI/CD in Mule Integration and Automat...Patryk Bandurski
 
AI as an Interface for Commercial Buildings
AI as an Interface for Commercial BuildingsAI as an Interface for Commercial Buildings
AI as an Interface for Commercial BuildingsMemoori
 
Beyond Boundaries: Leveraging No-Code Solutions for Industry Innovation
Beyond Boundaries: Leveraging No-Code Solutions for Industry InnovationBeyond Boundaries: Leveraging No-Code Solutions for Industry Innovation
Beyond Boundaries: Leveraging No-Code Solutions for Industry InnovationSafe Software
 
Understanding the Laravel MVC Architecture
Understanding the Laravel MVC ArchitectureUnderstanding the Laravel MVC Architecture
Understanding the Laravel MVC ArchitecturePixlogix Infotech
 
Pigging Solutions in Pet Food Manufacturing
Pigging Solutions in Pet Food ManufacturingPigging Solutions in Pet Food Manufacturing
Pigging Solutions in Pet Food ManufacturingPigging Solutions
 
Artificial intelligence in the post-deep learning era
Artificial intelligence in the post-deep learning eraArtificial intelligence in the post-deep learning era
Artificial intelligence in the post-deep learning eraDeakin University
 
Pigging Solutions Piggable Sweeping Elbows
Pigging Solutions Piggable Sweeping ElbowsPigging Solutions Piggable Sweeping Elbows
Pigging Solutions Piggable Sweeping ElbowsPigging Solutions
 
Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...
Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...
Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...shyamraj55
 
Slack Application Development 101 Slides
Slack Application Development 101 SlidesSlack Application Development 101 Slides
Slack Application Development 101 Slidespraypatel2
 

Recently uploaded (20)

FULL ENJOY 🔝 8264348440 🔝 Call Girls in Diplomatic Enclave | Delhi
FULL ENJOY 🔝 8264348440 🔝 Call Girls in Diplomatic Enclave | DelhiFULL ENJOY 🔝 8264348440 🔝 Call Girls in Diplomatic Enclave | Delhi
FULL ENJOY 🔝 8264348440 🔝 Call Girls in Diplomatic Enclave | Delhi
 
IAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI SolutionsIAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI Solutions
 
How to Remove Document Management Hurdles with X-Docs?
How to Remove Document Management Hurdles with X-Docs?How to Remove Document Management Hurdles with X-Docs?
How to Remove Document Management Hurdles with X-Docs?
 
Azure Monitor & Application Insight to monitor Infrastructure & Application
Azure Monitor & Application Insight to monitor Infrastructure & ApplicationAzure Monitor & Application Insight to monitor Infrastructure & Application
Azure Monitor & Application Insight to monitor Infrastructure & Application
 
Presentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreterPresentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreter
 
CloudStudio User manual (basic edition):
CloudStudio User manual (basic edition):CloudStudio User manual (basic edition):
CloudStudio User manual (basic edition):
 
Injustice - Developers Among Us (SciFiDevCon 2024)
Injustice - Developers Among Us (SciFiDevCon 2024)Injustice - Developers Among Us (SciFiDevCon 2024)
Injustice - Developers Among Us (SciFiDevCon 2024)
 
Benefits Of Flutter Compared To Other Frameworks
Benefits Of Flutter Compared To Other FrameworksBenefits Of Flutter Compared To Other Frameworks
Benefits Of Flutter Compared To Other Frameworks
 
E-Vehicle_Hacking_by_Parul Sharma_null_owasp.pptx
E-Vehicle_Hacking_by_Parul Sharma_null_owasp.pptxE-Vehicle_Hacking_by_Parul Sharma_null_owasp.pptx
E-Vehicle_Hacking_by_Parul Sharma_null_owasp.pptx
 
The Codex of Business Writing Software for Real-World Solutions 2.pptx
The Codex of Business Writing Software for Real-World Solutions 2.pptxThe Codex of Business Writing Software for Real-World Solutions 2.pptx
The Codex of Business Writing Software for Real-World Solutions 2.pptx
 
SQL Database Design For Developers at php[tek] 2024
SQL Database Design For Developers at php[tek] 2024SQL Database Design For Developers at php[tek] 2024
SQL Database Design For Developers at php[tek] 2024
 
Integration and Automation in Practice: CI/CD in Mule Integration and Automat...
Integration and Automation in Practice: CI/CD in Mule Integration and Automat...Integration and Automation in Practice: CI/CD in Mule Integration and Automat...
Integration and Automation in Practice: CI/CD in Mule Integration and Automat...
 
AI as an Interface for Commercial Buildings
AI as an Interface for Commercial BuildingsAI as an Interface for Commercial Buildings
AI as an Interface for Commercial Buildings
 
Beyond Boundaries: Leveraging No-Code Solutions for Industry Innovation
Beyond Boundaries: Leveraging No-Code Solutions for Industry InnovationBeyond Boundaries: Leveraging No-Code Solutions for Industry Innovation
Beyond Boundaries: Leveraging No-Code Solutions for Industry Innovation
 
Understanding the Laravel MVC Architecture
Understanding the Laravel MVC ArchitectureUnderstanding the Laravel MVC Architecture
Understanding the Laravel MVC Architecture
 
Pigging Solutions in Pet Food Manufacturing
Pigging Solutions in Pet Food ManufacturingPigging Solutions in Pet Food Manufacturing
Pigging Solutions in Pet Food Manufacturing
 
Artificial intelligence in the post-deep learning era
Artificial intelligence in the post-deep learning eraArtificial intelligence in the post-deep learning era
Artificial intelligence in the post-deep learning era
 
Pigging Solutions Piggable Sweeping Elbows
Pigging Solutions Piggable Sweeping ElbowsPigging Solutions Piggable Sweeping Elbows
Pigging Solutions Piggable Sweeping Elbows
 
Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...
Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...
Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...
 
Slack Application Development 101 Slides
Slack Application Development 101 SlidesSlack Application Development 101 Slides
Slack Application Development 101 Slides
 

Angular js

  • 1.
  • 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.
  • 9.
  • 10.
  • 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.