SlideShare a Scribd company logo
AngularJS
A better way to create web apps
Agenda
O Introduction to AngularJS
O Some concepts used in AngularJS
O Testing application built with Angular
O Productivity and debugging tools
O Code organization for large projects
O Code demo as we go on
Why AngularJS
O HTML was created to transmit markup
data on web. E.g. <b> tags for making text
bold etc.
O JavaScript added for interactivity.
O And then comes AJAX and rich web
apps.
O And things get messed up by adding
listeners after getting ids, callbacks and
series of callbacks.
What can AngularJS do
O Less boilerplate code, faster development
with less code and thus less tests and
bugs.
O Clean separation of DOM
manipulation, business logic and views
make things easier to test.
O Declarative UI design means designers
can focus on their work without even
knowing JavaScript.
O Support for cool stuff like promises.
Angular components
This is the real stuff
Angular App
Modules
Models
Controllers
Templates (and Views)
Directives
Services
Filters
Routes
Module
O Angular apps have nothing like a main
method
O Directive ng-app used to bootstrap the
module
O E.g. <html ng-app=“someModule”>
O A module can contain several other
components
O var module =
angular.module(„someModule‟, [])
O Second argument is an array of other
modules which are requisites for the current
module.
Models
O In Angular, model is any data that is
reachable as property of $scope object
O Can also create models inside templates
using the ng-model directive e.g. <input
type=“email” ng-model=“user.email”>
O Can watch models for changes using
$watch(watchFn, watchAction, deepWatch)
O deepWatch is a boolean which allows to
watch attributes of the object returned by
watchFn
Controllers
O Set up the $scope
O Add behavior to $scope
O All business logic to be written in here.
O Can use the one controller per template
to create really traditional websites.
Templates
O Specify how things should show up and
what happens on particular user actions.
O Angular templates are not the view in
MVC. Compiled angular templates are the
views.
O Declaratively create the UI using
directives.
Directives
O One of the most important part of Angular
O Allows you to extend HTML to define
custom tags, attributes and classes for UI
components.
Jquery UI Angular Directives
<div id=“tabs”>
<ul>
<li><a href=“#tabs-1”> Tab1</a></li>
<li><a href=“#tabs-2”> Tab2</a></li>
</ul>
<div id=“#tabs-1>Content</div>
<div id=“#tabs-2>Content2</div>
</div>
<script>
$(function() {
$(„#tabs”).tabs();
});
</script>
<tab-set>
<tab title=“Tab1”>Content</tab>
<tab title=“Tab2”>Content2</tab>
</tab-set>
Now what if you need tabs on
10 pages in your whole
application ?
Services
O Stuff required at various places e.g. by
various controllers.
O E.g. a http request to get list of blog posts
in a blogging application would be
required while showing all blog posts, in
the admin edit/publish view etc.
O Three different ways to create services
i.e. services, factory and provider.
Filters
O Filters are transformations applies to
objects
O Not important to logic used to process
models e.g. currency sign (like $)
O E.g. lowerCase, sort etc.
O Built-in filters like json
O Custom filters can be defined with
app.filter(„filterName‟, function (obj)
{})
Routes
O Used to map templates and associated
controller to URLs.
O Supports HTML5 mode where you get
history support.
O That‟s it !
Form Validation
O Provides special support for two
properties $valid, $invalid.
O Can use them like <button ng-
disabled=“!formName.$valid”> to disable a
form until its all elements are correct.
O polyfills for things like „required‟ on non-
HTML browsers
Server-side communication
O $http wraps the XHR to provide
asynchronous requests.
O $resource for interacting with RESTful
resources. (provided as a separate
module in angular-resource.js)
O $http requests support promises (talk
about this later)
Secrets of all the magic in
Angular
What actually happens
O Template loads with all the angular directives
O Angular script loads and after template
loading finishes, it looks for ng-app to find
application boundaries.
O Compile phase – Angular walks the DOM to
identify registered directive and transforms
them.
O Link Phase – This runs a link function for
each directive which typically creates listeners
on DOM or model and keeps view and model
in sync .
$scope
O $scope allows binding and
communication between controller and
templates.
O All the model objects are stored on it.
O Makes sense not to store everything on it
as it would degrade performance.
Data binding
O Binding two sources together and keep
then updated of changes.
O Angular supports two-way data binding.
O Change in models get reflected
everywhere in view.
O Changes in view gets reflected in the
model.
Dependency Injection
O Follows Law of Demeter or principle of
least knowledge.
O Instead of creating things, just ask for
what is required.
O E.g. to create a Car you need an engine
so instead of calling an engine Factory in
the constructor, pass an engine as
parameter.
O Makes things easier to test (e.g. mock
$http), less code and easier to change
later.
Promises
O A promise is an interface that deals with
objects that are returned or get filled in at
a future point in time.
O Current approach with callbacks has
problems of indentation while chaining
multiple calls, losing errors reported
between callbacks unless manually
handled and doing real stuff in innermost
callback.
Promises
O In angular a promise gives with a then
function which takes two functions as a
parameter for promises getting resolved
(success) or rejected (failure)
O A promise can be –
O chained so you do not get code with callbacks
inside callbacks that flows out of the screen.
O errors propagate and can be handled at the
end.
O Assurance that previous call finishes before
next call.
Testing apps built with
Angular
Why Test ?
O Things do what they are expected to do.
O Future addition of code does not affect
previous features.
O Reduces effort in the long run but maybe
pain to write initially.
Unit tests in Angular
O Test stuffs like controllers, filters, services
and directives.
O Separation of DOM code makes testing
easier and possible.
O Using Jasmine like syntax and Jasmine
Spy instead of real browser.
Karma
O Karma is a test runner in JavaScript
O Test on real devices
O Control the whole workflow from
command line.
O Lightening fast !!
Scenario tests
O End to end tests involving complete
feature.
O E.g. first page of a blog should display N
blog posts.
O Done using Karma in Angular
Tools for productivity
Yeoman m/
O Lightning-fast scaffolding
O Built-in preview server
O Integrated package management
O An awesome build process
O Unit testing using PhantomJS
Batarang
O Chrome extension for angular
O Provides performance metrics, see
scopes and values of properties in them.
O Can change the values and see the
change in realtime.
IDE plugins
O Webstorm plugin is awesome.
O Sublime text angular plugin.
Angular Future
O Animations
O Breaking down into components
O alternative syntax work without the
$scope thing but not really useful.
O Much More…
Best practices
Because you can still write yucky code in Angular
No DOM manipulation in
controller
Things which are to be used
in multiple controllers ?
Use services
To wrap third party plugins
like JQuery date-picker, use
directives
Write tests.
This one is for me 
Use promises, they are
awesome.
Code organization
O Angular seed style
O Yeoman Style
O Any style you prefer
Learn more about it
O Angular Channel on Youtube
O http://www.yearofmoo.com
O egghead.io
O Stack Overflow
O Quora 

More Related Content

What's hot (20)

Angular js
Angular jsAngular js
Angular js
Knoldus Inc.
 
Angular 5 presentation for beginners
Angular 5 presentation for beginnersAngular 5 presentation for beginners
Angular 5 presentation for beginners
Imran Qasim
 
Angular 9
Angular 9 Angular 9
Angular 9
Raja Vishnu
 
Angular material tutorial
Angular material tutorialAngular material tutorial
Angular material tutorial
HarikaReddy115
 
Angular 9 New features
Angular 9 New featuresAngular 9 New features
Angular 9 New features
Ahmed Bouchefra
 
Dependency Injection pattern in Angular
Dependency Injection pattern in AngularDependency Injection pattern in Angular
Dependency Injection pattern in Angular
Alexe Bogdan
 
Angular Routing Tutorial | AngularJS vs Angular Router | Angular Training | E...
Angular Routing Tutorial | AngularJS vs Angular Router | Angular Training | E...Angular Routing Tutorial | AngularJS vs Angular Router | Angular Training | E...
Angular Routing Tutorial | AngularJS vs Angular Router | Angular Training | E...
Edureka!
 
Angular components
Angular componentsAngular components
Angular components
Sultan Ahmed
 
Angular modules in depth
Angular modules in depthAngular modules in depth
Angular modules in depth
Christoffer Noring
 
The Basics Angular JS
The Basics Angular JS The Basics Angular JS
The Basics Angular JS
OrisysIndia
 
Dive into Angular, part 5: Experience
Dive into Angular, part 5: ExperienceDive into Angular, part 5: Experience
Dive into Angular, part 5: Experience
Oleksii Prohonnyi
 
Angular interview questions
Angular interview questionsAngular interview questions
Angular interview questions
Goa App
 
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
 
AngularJS Fundamentals + WebAPI
AngularJS Fundamentals + WebAPIAngularJS Fundamentals + WebAPI
AngularJS Fundamentals + WebAPI
Eric Wise
 
introduction to Angularjs basics
introduction to Angularjs basicsintroduction to Angularjs basics
introduction to Angularjs basics
Ravindra K
 
Angular Workshop_Sarajevo2
Angular Workshop_Sarajevo2Angular Workshop_Sarajevo2
Angular Workshop_Sarajevo2
Christoffer Noring
 
Adding User Management to Node.js
Adding User Management to Node.jsAdding User Management to Node.js
Adding User Management to Node.js
Dev_Events
 
Training On Angular Js
Training On Angular JsTraining On Angular Js
Training On Angular Js
Mahima Radhakrishnan
 
A gently introduction to AngularJS
A gently introduction to AngularJSA gently introduction to AngularJS
A gently introduction to AngularJS
Gregor Woiwode
 
Angular Seminar-js
Angular Seminar-jsAngular Seminar-js
Angular Seminar-js
Mindfire Solutions
 
Angular 5 presentation for beginners
Angular 5 presentation for beginnersAngular 5 presentation for beginners
Angular 5 presentation for beginners
Imran Qasim
 
Angular material tutorial
Angular material tutorialAngular material tutorial
Angular material tutorial
HarikaReddy115
 
Dependency Injection pattern in Angular
Dependency Injection pattern in AngularDependency Injection pattern in Angular
Dependency Injection pattern in Angular
Alexe Bogdan
 
Angular Routing Tutorial | AngularJS vs Angular Router | Angular Training | E...
Angular Routing Tutorial | AngularJS vs Angular Router | Angular Training | E...Angular Routing Tutorial | AngularJS vs Angular Router | Angular Training | E...
Angular Routing Tutorial | AngularJS vs Angular Router | Angular Training | E...
Edureka!
 
Angular components
Angular componentsAngular components
Angular components
Sultan Ahmed
 
The Basics Angular JS
The Basics Angular JS The Basics Angular JS
The Basics Angular JS
OrisysIndia
 
Dive into Angular, part 5: Experience
Dive into Angular, part 5: ExperienceDive into Angular, part 5: Experience
Dive into Angular, part 5: Experience
Oleksii Prohonnyi
 
Angular interview questions
Angular interview questionsAngular interview questions
Angular interview questions
Goa App
 
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
 
AngularJS Fundamentals + WebAPI
AngularJS Fundamentals + WebAPIAngularJS Fundamentals + WebAPI
AngularJS Fundamentals + WebAPI
Eric Wise
 
introduction to Angularjs basics
introduction to Angularjs basicsintroduction to Angularjs basics
introduction to Angularjs basics
Ravindra K
 
Adding User Management to Node.js
Adding User Management to Node.jsAdding User Management to Node.js
Adding User Management to Node.js
Dev_Events
 
A gently introduction to AngularJS
A gently introduction to AngularJSA gently introduction to AngularJS
A gently introduction to AngularJS
Gregor Woiwode
 

Viewers also liked (8)

AngularJS introduction
AngularJS introductionAngularJS introduction
AngularJS introduction
Tania Gonzales
 
An introduction to AngularJS
An introduction to AngularJSAn introduction to AngularJS
An introduction to AngularJS
Yogesh singh
 
AngularJS Introduction
AngularJS IntroductionAngularJS Introduction
AngularJS Introduction
Carlos Morales
 
Hands On Intro to Node.js
Hands On Intro to Node.jsHands On Intro to Node.js
Hands On Intro to Node.js
Chris Cowan
 
JS Frameworks - Angular Vs Backbone
JS Frameworks - Angular Vs BackboneJS Frameworks - Angular Vs Backbone
JS Frameworks - Angular Vs Backbone
Gourav Jain, MCTS®
 
How AngularJS Embraced Traditional Design Patterns
How AngularJS Embraced Traditional Design PatternsHow AngularJS Embraced Traditional Design Patterns
How AngularJS Embraced Traditional Design Patterns
Ran Mizrahi
 
Introduction to AngularJS
Introduction to AngularJSIntroduction to AngularJS
Introduction to AngularJS
Jamal Sinclair O'Garro
 
Getting Started with Angular 2
Getting Started with Angular 2Getting Started with Angular 2
Getting Started with Angular 2
FITC
 
AngularJS introduction
AngularJS introductionAngularJS introduction
AngularJS introduction
Tania Gonzales
 
An introduction to AngularJS
An introduction to AngularJSAn introduction to AngularJS
An introduction to AngularJS
Yogesh singh
 
AngularJS Introduction
AngularJS IntroductionAngularJS Introduction
AngularJS Introduction
Carlos Morales
 
Hands On Intro to Node.js
Hands On Intro to Node.jsHands On Intro to Node.js
Hands On Intro to Node.js
Chris Cowan
 
JS Frameworks - Angular Vs Backbone
JS Frameworks - Angular Vs BackboneJS Frameworks - Angular Vs Backbone
JS Frameworks - Angular Vs Backbone
Gourav Jain, MCTS®
 
How AngularJS Embraced Traditional Design Patterns
How AngularJS Embraced Traditional Design PatternsHow AngularJS Embraced Traditional Design Patterns
How AngularJS Embraced Traditional Design Patterns
Ran Mizrahi
 
Getting Started with Angular 2
Getting Started with Angular 2Getting Started with Angular 2
Getting Started with Angular 2
FITC
 
Ad

Similar to AngularJS Introduction (Talk given on Aug 5 2013) (20)

AngularJS in practice
AngularJS in practiceAngularJS in practice
AngularJS in practice
Eugene Fidelin
 
Angular js for Beginnners
Angular js for BeginnnersAngular js for Beginnners
Angular js for Beginnners
Santosh Kumar Kar
 
Building Better Web Apps with Angular.js (SXSW 2014)
Building Better Web Apps with Angular.js (SXSW 2014)Building Better Web Apps with Angular.js (SXSW 2014)
Building Better Web Apps with Angular.js (SXSW 2014)
kbekessy
 
AngularJS One Day Workshop
AngularJS One Day WorkshopAngularJS One Day Workshop
AngularJS One Day Workshop
Shyam Seshadri
 
ME vs WEB - AngularJS Fundamentals
ME vs WEB - AngularJS FundamentalsME vs WEB - AngularJS Fundamentals
ME vs WEB - AngularJS Fundamentals
Aviran Cohen
 
AngularJS Workshop
AngularJS WorkshopAngularJS Workshop
AngularJS Workshop
Gianluca Cacace
 
AngularJS in Production (CTO Forum)
AngularJS in Production (CTO Forum)AngularJS in Production (CTO Forum)
AngularJS in Production (CTO Forum)
Alex Ross
 
Angular js 1.0-fundamentals
Angular js 1.0-fundamentalsAngular js 1.0-fundamentals
Angular js 1.0-fundamentals
Venkatesh Narayanan
 
AngularJS Beginner Day One
AngularJS Beginner Day OneAngularJS Beginner Day One
AngularJS Beginner Day One
Troy Miles
 
Angular training - Day 3 - custom directives, $http, $resource, setup with ye...
Angular training - Day 3 - custom directives, $http, $resource, setup with ye...Angular training - Day 3 - custom directives, $http, $resource, setup with ye...
Angular training - Day 3 - custom directives, $http, $resource, setup with ye...
murtazahaveliwala
 
Intro to AngularJs
Intro to AngularJsIntro to AngularJs
Intro to AngularJs
SolTech, Inc.
 
Learning AngularJS - Complete coverage of AngularJS features and concepts
Learning AngularJS  - Complete coverage of AngularJS features and conceptsLearning AngularJS  - Complete coverage of AngularJS features and concepts
Learning AngularJS - Complete coverage of AngularJS features and concepts
Suresh Patidar
 
Angular workshop - Full Development Guide
Angular workshop - Full Development GuideAngular workshop - Full Development Guide
Angular workshop - Full Development Guide
Nitin Giri
 
Quick start with AngularJS
Quick start with AngularJSQuick start with AngularJS
Quick start with AngularJS
Iuliia Baranova
 
AngularJS training - Day 1 - Basics: Why, What and basic features of AngularJS
AngularJS training - Day 1 - Basics: Why, What and basic features of AngularJSAngularJS training - Day 1 - Basics: Why, What and basic features of AngularJS
AngularJS training - Day 1 - Basics: Why, What and basic features of AngularJS
murtazahaveliwala
 
Angular js
Angular jsAngular js
Angular js
Mauro Servienti
 
AngularJS - a radically different way of building Single Page Apps
AngularJS - a radically different way of building Single Page AppsAngularJS - a radically different way of building Single Page Apps
AngularJS - a radically different way of building Single Page Apps
jivkopetiov
 
Angular js
Angular jsAngular js
Angular js
yogi_solanki
 
AngularJS.part1
AngularJS.part1AngularJS.part1
AngularJS.part1
Andrey Kolodnitsky
 
Angular js
Angular jsAngular js
Angular js
Silver Touch Technologies Ltd
 
Building Better Web Apps with Angular.js (SXSW 2014)
Building Better Web Apps with Angular.js (SXSW 2014)Building Better Web Apps with Angular.js (SXSW 2014)
Building Better Web Apps with Angular.js (SXSW 2014)
kbekessy
 
AngularJS One Day Workshop
AngularJS One Day WorkshopAngularJS One Day Workshop
AngularJS One Day Workshop
Shyam Seshadri
 
ME vs WEB - AngularJS Fundamentals
ME vs WEB - AngularJS FundamentalsME vs WEB - AngularJS Fundamentals
ME vs WEB - AngularJS Fundamentals
Aviran Cohen
 
AngularJS in Production (CTO Forum)
AngularJS in Production (CTO Forum)AngularJS in Production (CTO Forum)
AngularJS in Production (CTO Forum)
Alex Ross
 
AngularJS Beginner Day One
AngularJS Beginner Day OneAngularJS Beginner Day One
AngularJS Beginner Day One
Troy Miles
 
Angular training - Day 3 - custom directives, $http, $resource, setup with ye...
Angular training - Day 3 - custom directives, $http, $resource, setup with ye...Angular training - Day 3 - custom directives, $http, $resource, setup with ye...
Angular training - Day 3 - custom directives, $http, $resource, setup with ye...
murtazahaveliwala
 
Learning AngularJS - Complete coverage of AngularJS features and concepts
Learning AngularJS  - Complete coverage of AngularJS features and conceptsLearning AngularJS  - Complete coverage of AngularJS features and concepts
Learning AngularJS - Complete coverage of AngularJS features and concepts
Suresh Patidar
 
Angular workshop - Full Development Guide
Angular workshop - Full Development GuideAngular workshop - Full Development Guide
Angular workshop - Full Development Guide
Nitin Giri
 
Quick start with AngularJS
Quick start with AngularJSQuick start with AngularJS
Quick start with AngularJS
Iuliia Baranova
 
AngularJS training - Day 1 - Basics: Why, What and basic features of AngularJS
AngularJS training - Day 1 - Basics: Why, What and basic features of AngularJSAngularJS training - Day 1 - Basics: Why, What and basic features of AngularJS
AngularJS training - Day 1 - Basics: Why, What and basic features of AngularJS
murtazahaveliwala
 
AngularJS - a radically different way of building Single Page Apps
AngularJS - a radically different way of building Single Page AppsAngularJS - a radically different way of building Single Page Apps
AngularJS - a radically different way of building Single Page Apps
jivkopetiov
 
Ad

Recently uploaded (20)

Create Your First AI Agent with UiPath Agent Builder
Create Your First AI Agent with UiPath Agent BuilderCreate Your First AI Agent with UiPath Agent Builder
Create Your First AI Agent with UiPath Agent Builder
DianaGray10
 
6th Power Grid Model Meetup - 21 May 2025
6th Power Grid Model Meetup - 21 May 20256th Power Grid Model Meetup - 21 May 2025
6th Power Grid Model Meetup - 21 May 2025
DanBrown980551
 
Droidal: AI Agents Revolutionizing Healthcare
Droidal: AI Agents Revolutionizing HealthcareDroidal: AI Agents Revolutionizing Healthcare
Droidal: AI Agents Revolutionizing Healthcare
Droidal LLC
 
Cybersecurity Fundamentals: Apprentice - Palo Alto Certificate
Cybersecurity Fundamentals: Apprentice - Palo Alto CertificateCybersecurity Fundamentals: Apprentice - Palo Alto Certificate
Cybersecurity Fundamentals: Apprentice - Palo Alto Certificate
VICTOR MAESTRE RAMIREZ
 
Cyber security cyber security cyber security cyber security cyber security cy...
Cyber security cyber security cyber security cyber security cyber security cy...Cyber security cyber security cyber security cyber security cyber security cy...
Cyber security cyber security cyber security cyber security cyber security cy...
pranavbodhak
 
Introducing the OSA 3200 SP and OSA 3250 ePRC
Introducing the OSA 3200 SP and OSA 3250 ePRCIntroducing the OSA 3200 SP and OSA 3250 ePRC
Introducing the OSA 3200 SP and OSA 3250 ePRC
Adtran
 
European Accessibility Act & Integrated Accessibility Testing
European Accessibility Act & Integrated Accessibility TestingEuropean Accessibility Act & Integrated Accessibility Testing
European Accessibility Act & Integrated Accessibility Testing
Julia Undeutsch
 
Co-Constructing Explanations for AI Systems using Provenance
Co-Constructing Explanations for AI Systems using ProvenanceCo-Constructing Explanations for AI Systems using Provenance
Co-Constructing Explanations for AI Systems using Provenance
Paul Groth
 
LSNIF: Locally-Subdivided Neural Intersection Function
LSNIF: Locally-Subdivided Neural Intersection FunctionLSNIF: Locally-Subdivided Neural Intersection Function
LSNIF: Locally-Subdivided Neural Intersection Function
Takahiro Harada
 
Contributing to WordPress With & Without Code.pptx
Contributing to WordPress With & Without Code.pptxContributing to WordPress With & Without Code.pptx
Contributing to WordPress With & Without Code.pptx
Patrick Lumumba
 
Let’s Get Slack Certified! 🚀- Slack Community
Let’s Get Slack Certified! 🚀- Slack CommunityLet’s Get Slack Certified! 🚀- Slack Community
Let’s Get Slack Certified! 🚀- Slack Community
SanjeetMishra29
 
Evaluation Challenges in Using Generative AI for Science & Technical Content
Evaluation Challenges in Using Generative AI for Science & Technical ContentEvaluation Challenges in Using Generative AI for Science & Technical Content
Evaluation Challenges in Using Generative AI for Science & Technical Content
Paul Groth
 
Measuring Microsoft 365 Copilot and Gen AI Success
Measuring Microsoft 365 Copilot and Gen AI SuccessMeasuring Microsoft 365 Copilot and Gen AI Success
Measuring Microsoft 365 Copilot and Gen AI Success
Nikki Chapple
 
Securiport - A Border Security Company
Securiport  -  A Border Security CompanySecuriport  -  A Border Security Company
Securiport - A Border Security Company
Securiport
 
Grannie’s Journey to Using Healthcare AI Experiences
Grannie’s Journey to Using Healthcare AI ExperiencesGrannie’s Journey to Using Healthcare AI Experiences
Grannie’s Journey to Using Healthcare AI Experiences
Lauren Parr
 
GDG Cloud Southlake #43: Tommy Todd: The Quantum Apocalypse: A Looming Threat...
GDG Cloud Southlake #43: Tommy Todd: The Quantum Apocalypse: A Looming Threat...GDG Cloud Southlake #43: Tommy Todd: The Quantum Apocalypse: A Looming Threat...
GDG Cloud Southlake #43: Tommy Todd: The Quantum Apocalypse: A Looming Threat...
James Anderson
 
Cognitive Chasms - A Typology of GenAI Failure Failure Modes
Cognitive Chasms - A Typology of GenAI Failure Failure ModesCognitive Chasms - A Typology of GenAI Failure Failure Modes
Cognitive Chasms - A Typology of GenAI Failure Failure Modes
Dr. Tathagat Varma
 
UiPath Community Berlin: Studio Tips & Tricks and UiPath Insights
UiPath Community Berlin: Studio Tips & Tricks and UiPath InsightsUiPath Community Berlin: Studio Tips & Tricks and UiPath Insights
UiPath Community Berlin: Studio Tips & Tricks and UiPath Insights
UiPathCommunity
 
Jira Administration Training – Day 1 : Introduction
Jira Administration Training – Day 1 : IntroductionJira Administration Training – Day 1 : Introduction
Jira Administration Training – Day 1 : Introduction
Ravi Teja
 
New Ways to Reduce Database Costs with ScyllaDB
New Ways to Reduce Database Costs with ScyllaDBNew Ways to Reduce Database Costs with ScyllaDB
New Ways to Reduce Database Costs with ScyllaDB
ScyllaDB
 
Create Your First AI Agent with UiPath Agent Builder
Create Your First AI Agent with UiPath Agent BuilderCreate Your First AI Agent with UiPath Agent Builder
Create Your First AI Agent with UiPath Agent Builder
DianaGray10
 
6th Power Grid Model Meetup - 21 May 2025
6th Power Grid Model Meetup - 21 May 20256th Power Grid Model Meetup - 21 May 2025
6th Power Grid Model Meetup - 21 May 2025
DanBrown980551
 
Droidal: AI Agents Revolutionizing Healthcare
Droidal: AI Agents Revolutionizing HealthcareDroidal: AI Agents Revolutionizing Healthcare
Droidal: AI Agents Revolutionizing Healthcare
Droidal LLC
 
Cybersecurity Fundamentals: Apprentice - Palo Alto Certificate
Cybersecurity Fundamentals: Apprentice - Palo Alto CertificateCybersecurity Fundamentals: Apprentice - Palo Alto Certificate
Cybersecurity Fundamentals: Apprentice - Palo Alto Certificate
VICTOR MAESTRE RAMIREZ
 
Cyber security cyber security cyber security cyber security cyber security cy...
Cyber security cyber security cyber security cyber security cyber security cy...Cyber security cyber security cyber security cyber security cyber security cy...
Cyber security cyber security cyber security cyber security cyber security cy...
pranavbodhak
 
Introducing the OSA 3200 SP and OSA 3250 ePRC
Introducing the OSA 3200 SP and OSA 3250 ePRCIntroducing the OSA 3200 SP and OSA 3250 ePRC
Introducing the OSA 3200 SP and OSA 3250 ePRC
Adtran
 
European Accessibility Act & Integrated Accessibility Testing
European Accessibility Act & Integrated Accessibility TestingEuropean Accessibility Act & Integrated Accessibility Testing
European Accessibility Act & Integrated Accessibility Testing
Julia Undeutsch
 
Co-Constructing Explanations for AI Systems using Provenance
Co-Constructing Explanations for AI Systems using ProvenanceCo-Constructing Explanations for AI Systems using Provenance
Co-Constructing Explanations for AI Systems using Provenance
Paul Groth
 
LSNIF: Locally-Subdivided Neural Intersection Function
LSNIF: Locally-Subdivided Neural Intersection FunctionLSNIF: Locally-Subdivided Neural Intersection Function
LSNIF: Locally-Subdivided Neural Intersection Function
Takahiro Harada
 
Contributing to WordPress With & Without Code.pptx
Contributing to WordPress With & Without Code.pptxContributing to WordPress With & Without Code.pptx
Contributing to WordPress With & Without Code.pptx
Patrick Lumumba
 
Let’s Get Slack Certified! 🚀- Slack Community
Let’s Get Slack Certified! 🚀- Slack CommunityLet’s Get Slack Certified! 🚀- Slack Community
Let’s Get Slack Certified! 🚀- Slack Community
SanjeetMishra29
 
Evaluation Challenges in Using Generative AI for Science & Technical Content
Evaluation Challenges in Using Generative AI for Science & Technical ContentEvaluation Challenges in Using Generative AI for Science & Technical Content
Evaluation Challenges in Using Generative AI for Science & Technical Content
Paul Groth
 
Measuring Microsoft 365 Copilot and Gen AI Success
Measuring Microsoft 365 Copilot and Gen AI SuccessMeasuring Microsoft 365 Copilot and Gen AI Success
Measuring Microsoft 365 Copilot and Gen AI Success
Nikki Chapple
 
Securiport - A Border Security Company
Securiport  -  A Border Security CompanySecuriport  -  A Border Security Company
Securiport - A Border Security Company
Securiport
 
Grannie’s Journey to Using Healthcare AI Experiences
Grannie’s Journey to Using Healthcare AI ExperiencesGrannie’s Journey to Using Healthcare AI Experiences
Grannie’s Journey to Using Healthcare AI Experiences
Lauren Parr
 
GDG Cloud Southlake #43: Tommy Todd: The Quantum Apocalypse: A Looming Threat...
GDG Cloud Southlake #43: Tommy Todd: The Quantum Apocalypse: A Looming Threat...GDG Cloud Southlake #43: Tommy Todd: The Quantum Apocalypse: A Looming Threat...
GDG Cloud Southlake #43: Tommy Todd: The Quantum Apocalypse: A Looming Threat...
James Anderson
 
Cognitive Chasms - A Typology of GenAI Failure Failure Modes
Cognitive Chasms - A Typology of GenAI Failure Failure ModesCognitive Chasms - A Typology of GenAI Failure Failure Modes
Cognitive Chasms - A Typology of GenAI Failure Failure Modes
Dr. Tathagat Varma
 
UiPath Community Berlin: Studio Tips & Tricks and UiPath Insights
UiPath Community Berlin: Studio Tips & Tricks and UiPath InsightsUiPath Community Berlin: Studio Tips & Tricks and UiPath Insights
UiPath Community Berlin: Studio Tips & Tricks and UiPath Insights
UiPathCommunity
 
Jira Administration Training – Day 1 : Introduction
Jira Administration Training – Day 1 : IntroductionJira Administration Training – Day 1 : Introduction
Jira Administration Training – Day 1 : Introduction
Ravi Teja
 
New Ways to Reduce Database Costs with ScyllaDB
New Ways to Reduce Database Costs with ScyllaDBNew Ways to Reduce Database Costs with ScyllaDB
New Ways to Reduce Database Costs with ScyllaDB
ScyllaDB
 

AngularJS Introduction (Talk given on Aug 5 2013)

  • 1. AngularJS A better way to create web apps
  • 2. Agenda O Introduction to AngularJS O Some concepts used in AngularJS O Testing application built with Angular O Productivity and debugging tools O Code organization for large projects O Code demo as we go on
  • 3. Why AngularJS O HTML was created to transmit markup data on web. E.g. <b> tags for making text bold etc. O JavaScript added for interactivity. O And then comes AJAX and rich web apps. O And things get messed up by adding listeners after getting ids, callbacks and series of callbacks.
  • 4. What can AngularJS do O Less boilerplate code, faster development with less code and thus less tests and bugs. O Clean separation of DOM manipulation, business logic and views make things easier to test. O Declarative UI design means designers can focus on their work without even knowing JavaScript. O Support for cool stuff like promises.
  • 5. Angular components This is the real stuff
  • 6. Angular App Modules Models Controllers Templates (and Views) Directives Services Filters Routes
  • 7. Module O Angular apps have nothing like a main method O Directive ng-app used to bootstrap the module O E.g. <html ng-app=“someModule”> O A module can contain several other components O var module = angular.module(„someModule‟, []) O Second argument is an array of other modules which are requisites for the current module.
  • 8. Models O In Angular, model is any data that is reachable as property of $scope object O Can also create models inside templates using the ng-model directive e.g. <input type=“email” ng-model=“user.email”> O Can watch models for changes using $watch(watchFn, watchAction, deepWatch) O deepWatch is a boolean which allows to watch attributes of the object returned by watchFn
  • 9. Controllers O Set up the $scope O Add behavior to $scope O All business logic to be written in here. O Can use the one controller per template to create really traditional websites.
  • 10. Templates O Specify how things should show up and what happens on particular user actions. O Angular templates are not the view in MVC. Compiled angular templates are the views. O Declaratively create the UI using directives.
  • 11. Directives O One of the most important part of Angular O Allows you to extend HTML to define custom tags, attributes and classes for UI components. Jquery UI Angular Directives <div id=“tabs”> <ul> <li><a href=“#tabs-1”> Tab1</a></li> <li><a href=“#tabs-2”> Tab2</a></li> </ul> <div id=“#tabs-1>Content</div> <div id=“#tabs-2>Content2</div> </div> <script> $(function() { $(„#tabs”).tabs(); }); </script> <tab-set> <tab title=“Tab1”>Content</tab> <tab title=“Tab2”>Content2</tab> </tab-set> Now what if you need tabs on 10 pages in your whole application ?
  • 12. Services O Stuff required at various places e.g. by various controllers. O E.g. a http request to get list of blog posts in a blogging application would be required while showing all blog posts, in the admin edit/publish view etc. O Three different ways to create services i.e. services, factory and provider.
  • 13. Filters O Filters are transformations applies to objects O Not important to logic used to process models e.g. currency sign (like $) O E.g. lowerCase, sort etc. O Built-in filters like json O Custom filters can be defined with app.filter(„filterName‟, function (obj) {})
  • 14. Routes O Used to map templates and associated controller to URLs. O Supports HTML5 mode where you get history support. O That‟s it !
  • 15. Form Validation O Provides special support for two properties $valid, $invalid. O Can use them like <button ng- disabled=“!formName.$valid”> to disable a form until its all elements are correct. O polyfills for things like „required‟ on non- HTML browsers
  • 16. Server-side communication O $http wraps the XHR to provide asynchronous requests. O $resource for interacting with RESTful resources. (provided as a separate module in angular-resource.js) O $http requests support promises (talk about this later)
  • 17. Secrets of all the magic in Angular
  • 18. What actually happens O Template loads with all the angular directives O Angular script loads and after template loading finishes, it looks for ng-app to find application boundaries. O Compile phase – Angular walks the DOM to identify registered directive and transforms them. O Link Phase – This runs a link function for each directive which typically creates listeners on DOM or model and keeps view and model in sync .
  • 19. $scope O $scope allows binding and communication between controller and templates. O All the model objects are stored on it. O Makes sense not to store everything on it as it would degrade performance.
  • 20. Data binding O Binding two sources together and keep then updated of changes. O Angular supports two-way data binding. O Change in models get reflected everywhere in view. O Changes in view gets reflected in the model.
  • 21. Dependency Injection O Follows Law of Demeter or principle of least knowledge. O Instead of creating things, just ask for what is required. O E.g. to create a Car you need an engine so instead of calling an engine Factory in the constructor, pass an engine as parameter. O Makes things easier to test (e.g. mock $http), less code and easier to change later.
  • 22. Promises O A promise is an interface that deals with objects that are returned or get filled in at a future point in time. O Current approach with callbacks has problems of indentation while chaining multiple calls, losing errors reported between callbacks unless manually handled and doing real stuff in innermost callback.
  • 23. Promises O In angular a promise gives with a then function which takes two functions as a parameter for promises getting resolved (success) or rejected (failure) O A promise can be – O chained so you do not get code with callbacks inside callbacks that flows out of the screen. O errors propagate and can be handled at the end. O Assurance that previous call finishes before next call.
  • 24. Testing apps built with Angular
  • 25. Why Test ? O Things do what they are expected to do. O Future addition of code does not affect previous features. O Reduces effort in the long run but maybe pain to write initially.
  • 26. Unit tests in Angular O Test stuffs like controllers, filters, services and directives. O Separation of DOM code makes testing easier and possible. O Using Jasmine like syntax and Jasmine Spy instead of real browser.
  • 27. Karma O Karma is a test runner in JavaScript O Test on real devices O Control the whole workflow from command line. O Lightening fast !!
  • 28. Scenario tests O End to end tests involving complete feature. O E.g. first page of a blog should display N blog posts. O Done using Karma in Angular
  • 30. Yeoman m/ O Lightning-fast scaffolding O Built-in preview server O Integrated package management O An awesome build process O Unit testing using PhantomJS
  • 31. Batarang O Chrome extension for angular O Provides performance metrics, see scopes and values of properties in them. O Can change the values and see the change in realtime.
  • 32. IDE plugins O Webstorm plugin is awesome. O Sublime text angular plugin.
  • 33. Angular Future O Animations O Breaking down into components O alternative syntax work without the $scope thing but not really useful. O Much More…
  • 34. Best practices Because you can still write yucky code in Angular
  • 35. No DOM manipulation in controller
  • 36. Things which are to be used in multiple controllers ? Use services
  • 37. To wrap third party plugins like JQuery date-picker, use directives
  • 38. Write tests. This one is for me 
  • 39. Use promises, they are awesome.
  • 40. Code organization O Angular seed style O Yeoman Style O Any style you prefer
  • 41. Learn more about it O Angular Channel on Youtube O http://www.yearofmoo.com O egghead.io O Stack Overflow O Quora 

Editor's Notes

  • #14:  Angular comes with several filters, like currency, which we’ve seen:{{12.9 | currency}}This bit of code will display the following:$12.90We put this declaration in the view (rather than in the controller or model) because thedollar sign in front of the number is only important to humans, and not to the logic weuse to process the number.varhomeModule = angular.module(&apos;HomeModule&apos;, []);homeModule.filter(&apos;titleCase&apos;, function() {vartitleCaseFilter = function(input) {varwords = input.split(&apos; &apos;);for (vari = 0; i &lt; words.length; i++) {words[i] = words[i].charAt(0).toUpperCase() + words[i].slice(1);}return words.join(&apos; &apos;);};return titleCaseFilter;});
  • #19: Script loadsAngular loads and looks for the ng-app directive to find the application boundaries.Compile phaseIn this phase, Angular walks the DOM to identify all the registered directives in thetemplate. For each directive, it then transforms the DOM based on the directive’srules (template, replace, transclude, and so on), and calls the compile functionif it exists. The result is a compiled template function, which will invoke the linkfunctions collected from all of the directives.Link phaseTo make the view dynamic, Angular then runs a link function for each directive.The link functions typically creates listeners on the DOM or the model. Theselisteners keep the view and the model in sync at all times. …. functions deal with transforming the template itself, and link functions deal with makinga dynamic connection between model and view. It is in this second phase that scopesare attached to the compiled link functions, and the directive becomes live throughdata binding. These two phases are separate for performance reasons. Compile functions execute onlyonce in the compile phase, whereas link functions are executed many times, once foreach instance of the directive. For example, let’s say you use ng-repeat over your directive.You don’t want to call compile, which causes a DOM-walk on each ngrepeatiteration. Instead, you want to compile once, then link.