SlideShare a Scribd company logo
INTRO TO ANGULAR 2 & COMPARISION WITH
ANGULAR 1.X
NIKHIL KUMAR | SOFTWARE CONSULTANT
Knoldus Software LLP
AGENDA
l
INTRODUCTION to NG 2.0 & CONCEPTS
l
WHY NEW VERSION ?
l
MAJOR KEY FEATURES
l
PROBLEMS IN 1.X & SOLUTIONS IN 2.0
l
WEB COMPONENTS
l
MIGRATION PATH TO ANGULAR 2
AngularJS 1.3 is by far the best version of Angular available
today. It was just released a few weeks ago. It's chock full of bug
fixes, feature enhancements and performance improvements.
HISTORY & STABILITY
Why Angular 2
A framework that cannot work with Web Components, bogs down on mobile or
continues to push its own module and class API against the standards, is not
going to last long. The Angular team's answer to these problems is a new
version: Angular 2.0. It is essentially a re-imagining of AngularJS for the
modern web, taking into account everything that has been learned over the
last five years.
YEAHHHHH..... :D
Web Components?
Web Components are on the horizon. The term Web Components usually
refers to a collection of four related W3C specifications:
Custom Elements - Enables the extension of HTML through custom tags.
HTML Imports - Enables packaging of various resources (HTML, CSS, JS, etc.).
Template Element - Enables the inclusion of inert HTML in a document.
Shadow DOM - Enables encapsulation of DOM and CSS.
ES ?
ECMA Script specification is a standardardized specification of a
scripting language developed by Brendan of Netscape, initially it was
named Mocha, later LiveScript and finally JavaScript.
In 1995 Sun & Netscape annnouced Javascript.
Directives
In Angular 2.0 there will be three kinds of directives:
Component Directives – These will create reusable components by
encapsulating logic in JavaScript, HTML or an optional CSS style sheet.
Decorator Directives – These directives will be used to decorate
elements (for example adding a tooltip, or showing/hiding elements using
ng-show/ng-hide).
Template Directives – These will turn HTML into a reusable template. The
instantiating of the template and its insertion into the DOM can be
fully controlled by the directive author. Examples include ng-if and ng-
repeat.
Structure Should/May be link:
root-app-folder
├── index.html
├── scripts
│ ├── controllers
│ │ └── main.js
│ │ └── ...
│ ├── directives
│ │ └── myDirective.js
│ │ └── ...
│ ├── filters
│ │ └── myFilter.js
│ │ └── ...
│ ├── services
│ │ └── myService.js
│ │ └── ...
│ ├── vendor
│ │ ├── angular.js
│ │ ├── angular.min.js
│ │ ├── es5-shim.min.js
│ │ └── json3.min.js
│ └── app.js
├── styles
│ └── ...
└── views
├── main.html
└── ...
Key Features
● Mobile First
● Digest cycle
● Future Ready
● Speed & Performance
● Simple & Expressive
● Hierarchical Dependency Injection
● Support for Web Components
Differences with features
1- no digest cycle finished event
2- How Faster
3- Improved dependency injection
4- Directives Strategy etc
No digest cycle finished event
$scope.$watch, $scope.$apply, $timeout.
$scope.$watch('variable',function(newValue,oldValue){
 
});
because such event might trigger further changes that kept the digest cycle going.
we had to reason about when to call $scope.apply or $scope.digest,
which was not always straightforward
on occasion we had to call $timeout to let Angular finish its digest cycle
and do some operation only when the DOM is stable
No digest cycle finished event...
Problems:
Its not clear which watchers will be fired and in which order, or how many times
the order of the model updates is hard to reason about and anticipate
the digest cycle can run multiple times(thats why no digest life cycle finished event)
which is time consuming
Solution:
One of the first steps that the Angular team took in the direction of Angular 2,
was to extract from the Angular code base the mechanism of patching all asynchronous
interaction points, and made it reusable.
SOLUTION...
$scope.$watch, $scope.$apply, $timeout. No more. Whew! Using these was
part of the reason Angular 1.x had such a huge learning curve.
Zone.js helps Angular to do change detection automatically.
This sounds similar to React's reconciliation diffing
algorithm.
element.addEventListener('keyup', function () {  
  console.log('Key pressed.');
});
});
WHY ANGULAR 2.0 IS FASTER
1- Faster checking of a single binding
2- Avoid scanning parts of the component tree
Improved dependency injection
Problem in Angluar 1.x
Angular 1 has a global pool of objects:
Improved dependency injection
Solution in Angluar 2
In Angular 2 there will be only one DI mechanism:
constructor injection by type.
The fact that there is only one mechanism makes it easier to learn. Also the
dependency injector is hierarchical, meaning that at different points of the
component tree it's possible to have different implementations of the same type.
Ng-directives
Components in the HTML are broken up into two
types: (events) & [properties].
1.x 2.0
ng-click (click) (dbl-click)
ng-keyup (keyup)
(events) refer to user initiated actions.
[properties] now link directly into the DOM properties.
1.x 2.0
ng-hide [class:hidden]
ng-checked [checked]
*foreach
!foreach is the proposed replacement for ng-repeat.
<ul> <li *foreach="#item in itemService.items"></li> </ul>
#item
Items prefixed with a # can bind directly in the html. No more ng-model.
<input type="text" #userName />
Migration Path to angular 2
The new Angular 2 router is being backported to
Angular 1, and will allow the same application to have
both Angular 1 and Angular 2 routes.
It will be possible to mix Angular 1 and Angular 2
components in the same application
It will be possible to inject services across framework
versions.
Data binding will work accross versions as the two
change detection mechanisms will be integrated.
Component...?
To build an Angular 2 application you define a set of components, for
every UI element, screen, and route. An application will always have a
root component that contains all other components. In other words,
every Angular 2 application will have a component tree
Component...
@Component({
selector: 'talk-cmp',
properties: ['talk'],
events: ['rate']
})
@View({
directives: [FormattedRating, WatchButton, RateButton],
templateUrl: 'talk_cmp.html'
})
Talk_cmp.html
{{talk.title}}
{{talk.speaker}}
Demo…
http://tryangular2.github.io/#/section-1/page-1
http://www.codeproject.com/Tips/990533/Hello-Angular
http://eisenbergeffect.bluespire.com/all-about-angular-2-0/
References
Thank You

More Related Content

PDF
Observables in Angular
Knoldus Inc.
 
PPTX
Angular
Mouad EL Fakir
 
PPTX
Angular 5 presentation for beginners
Imran Qasim
 
PPT
Angular App Presentation
Elizabeth Long
 
PDF
Angular directives and pipes
Knoldus Inc.
 
PPTX
Angular overview
Thanvilahari
 
PPT
Angular Introduction By Surekha Gadkari
Surekha Gadkari
 
PDF
Angular - Chapter 7 - HTTP Services
WebStackAcademy
 
Observables in Angular
Knoldus Inc.
 
Angular 5 presentation for beginners
Imran Qasim
 
Angular App Presentation
Elizabeth Long
 
Angular directives and pipes
Knoldus Inc.
 
Angular overview
Thanvilahari
 
Angular Introduction By Surekha Gadkari
Surekha Gadkari
 
Angular - Chapter 7 - HTTP Services
WebStackAcademy
 

What's hot (20)

PPTX
Angular Data Binding
Jennifer Estrada
 
PPTX
What’s New in Angular 14?
Albiorix Technology
 
PPTX
Angular 9
Raja Vishnu
 
PPTX
Angular Directives
Malla Reddy University
 
PPTX
Introduction to angular with a simple but complete project
Jadson Santos
 
PDF
Angular Directives
iFour Technolab Pvt. Ltd.
 
PPTX
Angular 14.pptx
MohaNedGhawar
 
PPTX
Angular modules in depth
Christoffer Noring
 
PDF
Angular
Lilia Sfaxi
 
PPTX
Angular introduction students
Christian John Felix
 
KEY
Introduction to Django
James Casey
 
PPTX
Angularjs PPT
Amit Baghel
 
PDF
OpenAPI 3.0, And What It Means for the Future of Swagger
SmartBear
 
PPTX
Presentation web based application|Web designing training center in coimbator...
Vignesh026
 
PPTX
Presentation of framework Angular
Lhouceine OUHAMZA
 
PPTX
REST API Design & Development
Ashok Pundit
 
PPTX
Introduction to AngularJS
David Parsons
 
PDF
The New JavaScript: ES6
Rob Eisenberg
 
Angular Data Binding
Jennifer Estrada
 
What’s New in Angular 14?
Albiorix Technology
 
Angular 9
Raja Vishnu
 
Angular Directives
Malla Reddy University
 
Introduction to angular with a simple but complete project
Jadson Santos
 
Angular Directives
iFour Technolab Pvt. Ltd.
 
Angular 14.pptx
MohaNedGhawar
 
Angular modules in depth
Christoffer Noring
 
Angular
Lilia Sfaxi
 
Angular introduction students
Christian John Felix
 
Introduction to Django
James Casey
 
Angularjs PPT
Amit Baghel
 
OpenAPI 3.0, And What It Means for the Future of Swagger
SmartBear
 
Presentation web based application|Web designing training center in coimbator...
Vignesh026
 
Presentation of framework Angular
Lhouceine OUHAMZA
 
REST API Design & Development
Ashok Pundit
 
Introduction to AngularJS
David Parsons
 
The New JavaScript: ES6
Rob Eisenberg
 
Ad

Viewers also liked (11)

PDF
Building Universal Applications with Angular 2
Minko Gechev
 
PDF
Getting Started with Angular 2
FITC
 
PDF
Angular 2 - Core Concepts
Fabio Biondi
 
PPTX
PPT on Angular 2 Development Tutorial
Paddy Lock
 
PDF
Tech Webinar: Angular 2, Introduction to a new framework
Codemotion
 
PDF
Angular 2 overview
Jesse Warden
 
PDF
Angular Seminar [한빛미디어 리얼타임 세미나]
Woojin Joe
 
PPTX
Angular vs. React
OPITZ CONSULTING Deutschland
 
PPTX
Introduction to Angularjs
Manish Shekhawat
 
PDF
Introduction à Angular 2
Vincent Caillierez
 
PDF
Angular Extreme Performance
Gustavo Costa
 
Building Universal Applications with Angular 2
Minko Gechev
 
Getting Started with Angular 2
FITC
 
Angular 2 - Core Concepts
Fabio Biondi
 
PPT on Angular 2 Development Tutorial
Paddy Lock
 
Tech Webinar: Angular 2, Introduction to a new framework
Codemotion
 
Angular 2 overview
Jesse Warden
 
Angular Seminar [한빛미디어 리얼타임 세미나]
Woojin Joe
 
Angular vs. React
OPITZ CONSULTING Deutschland
 
Introduction to Angularjs
Manish Shekhawat
 
Introduction à Angular 2
Vincent Caillierez
 
Angular Extreme Performance
Gustavo Costa
 
Ad

Similar to Introduction to Angular 2 (20)

PPTX
What's new in Angular 2?
Alfred Jett Grandeza
 
PDF
An Intro to Angular 2
Ron Heft
 
PPTX
What’s new in angular 2 - From FrontEnd IL Meetup
Ran Wahle
 
PPTX
What’s new in angular 2
Ran Wahle
 
PDF
Angular 2 - How we got here?
Marios Fakiolas
 
PDF
Ng-Conf 2015 Report : AngularJS 1 & 2
Nicolas PENNEC
 
PDF
AngularJS Workshop
Gianluca Cacace
 
PPTX
Angular 2.0
Nitin Giri
 
PPTX
AngularJS 2.0
Boyan Mihaylov
 
PPTX
Angular 2.0
Mallikarjuna G D
 
ODP
Building scalable modular app with Angular2 concept
kzw
 
ODP
Building scalable modular app with Angular2 concept
kzw
 
PPTX
Angular2v2
Yoeri Van Damme
 
PPTX
Angular2 and You
Joseph Jorden
 
PPTX
Angular 2
Travis van der Font
 
PPTX
Angular js 2.0 beta
Nagaraju Sangam
 
PPTX
Сергей Больщиков "Angular Components: все уже за, а вы еще нет?"
Fwdays
 
PPTX
Angular%201%20to%20angular%202
Ran Wahle
 
PPTX
Introduction to Angular js 2.0
Nagaraju Sangam
 
PPTX
Practical AngularJS
Wei Ru
 
What's new in Angular 2?
Alfred Jett Grandeza
 
An Intro to Angular 2
Ron Heft
 
What’s new in angular 2 - From FrontEnd IL Meetup
Ran Wahle
 
What’s new in angular 2
Ran Wahle
 
Angular 2 - How we got here?
Marios Fakiolas
 
Ng-Conf 2015 Report : AngularJS 1 & 2
Nicolas PENNEC
 
AngularJS Workshop
Gianluca Cacace
 
Angular 2.0
Nitin Giri
 
AngularJS 2.0
Boyan Mihaylov
 
Angular 2.0
Mallikarjuna G D
 
Building scalable modular app with Angular2 concept
kzw
 
Building scalable modular app with Angular2 concept
kzw
 
Angular2v2
Yoeri Van Damme
 
Angular2 and You
Joseph Jorden
 
Angular js 2.0 beta
Nagaraju Sangam
 
Сергей Больщиков "Angular Components: все уже за, а вы еще нет?"
Fwdays
 
Angular%201%20to%20angular%202
Ran Wahle
 
Introduction to Angular js 2.0
Nagaraju Sangam
 
Practical AngularJS
Wei Ru
 

More from Knoldus Inc. (20)

PPTX
Angular Hydration Presentation (FrontEnd)
Knoldus Inc.
 
PPTX
Optimizing Test Execution: Heuristic Algorithm for Self-Healing
Knoldus Inc.
 
PPTX
Self-Healing Test Automation Framework - Healenium
Knoldus Inc.
 
PPTX
Kanban Metrics Presentation (Project Management)
Knoldus Inc.
 
PPTX
Java 17 features and implementation.pptx
Knoldus Inc.
 
PPTX
Chaos Mesh Introducing Chaos in Kubernetes
Knoldus Inc.
 
PPTX
GraalVM - A Step Ahead of JVM Presentation
Knoldus Inc.
 
PPTX
Nomad by HashiCorp Presentation (DevOps)
Knoldus Inc.
 
PPTX
Nomad by HashiCorp Presentation (DevOps)
Knoldus Inc.
 
PPTX
DAPR - Distributed Application Runtime Presentation
Knoldus Inc.
 
PPTX
Introduction to Azure Virtual WAN Presentation
Knoldus Inc.
 
PPTX
Introduction to Argo Rollouts Presentation
Knoldus Inc.
 
PPTX
Intro to Azure Container App Presentation
Knoldus Inc.
 
PPTX
Insights Unveiled Test Reporting and Observability Excellence
Knoldus Inc.
 
PPTX
Introduction to Splunk Presentation (DevOps)
Knoldus Inc.
 
PPTX
Code Camp - Data Profiling and Quality Analysis Framework
Knoldus Inc.
 
PPTX
AWS: Messaging Services in AWS Presentation
Knoldus Inc.
 
PPTX
Amazon Cognito: A Primer on Authentication and Authorization
Knoldus Inc.
 
PPTX
ZIO Http A Functional Approach to Scalable and Type-Safe Web Development
Knoldus Inc.
 
PPTX
Managing State & HTTP Requests In Ionic.
Knoldus Inc.
 
Angular Hydration Presentation (FrontEnd)
Knoldus Inc.
 
Optimizing Test Execution: Heuristic Algorithm for Self-Healing
Knoldus Inc.
 
Self-Healing Test Automation Framework - Healenium
Knoldus Inc.
 
Kanban Metrics Presentation (Project Management)
Knoldus Inc.
 
Java 17 features and implementation.pptx
Knoldus Inc.
 
Chaos Mesh Introducing Chaos in Kubernetes
Knoldus Inc.
 
GraalVM - A Step Ahead of JVM Presentation
Knoldus Inc.
 
Nomad by HashiCorp Presentation (DevOps)
Knoldus Inc.
 
Nomad by HashiCorp Presentation (DevOps)
Knoldus Inc.
 
DAPR - Distributed Application Runtime Presentation
Knoldus Inc.
 
Introduction to Azure Virtual WAN Presentation
Knoldus Inc.
 
Introduction to Argo Rollouts Presentation
Knoldus Inc.
 
Intro to Azure Container App Presentation
Knoldus Inc.
 
Insights Unveiled Test Reporting and Observability Excellence
Knoldus Inc.
 
Introduction to Splunk Presentation (DevOps)
Knoldus Inc.
 
Code Camp - Data Profiling and Quality Analysis Framework
Knoldus Inc.
 
AWS: Messaging Services in AWS Presentation
Knoldus Inc.
 
Amazon Cognito: A Primer on Authentication and Authorization
Knoldus Inc.
 
ZIO Http A Functional Approach to Scalable and Type-Safe Web Development
Knoldus Inc.
 
Managing State & HTTP Requests In Ionic.
Knoldus Inc.
 

Recently uploaded (20)

PDF
NewMind AI Weekly Chronicles - July'25 - Week IV
NewMind AI
 
PPTX
Stamford - Community User Group Leaders_ Agentblazer Status, AI Sustainabilit...
Amol Dixit
 
PDF
Revolutionize Operations with Intelligent IoT Monitoring and Control
Rejig Digital
 
PPTX
cloud computing vai.pptx for the project
vaibhavdobariyal79
 
PDF
Presentation about Hardware and Software in Computer
snehamodhawadiya
 
PDF
A Day in the Life of Location Data - Turning Where into How.pdf
Precisely
 
PPT
L2 Rules of Netiquette in Empowerment technology
Archibal2
 
PDF
Using Anchore and DefectDojo to Stand Up Your DevSecOps Function
Anchore
 
PDF
This slide provides an overview Technology
mineshkharadi333
 
PDF
Building High-Performance Oracle Teams: Strategic Staffing for Database Manag...
SMACT Works
 
PPTX
Coupa-Overview _Assumptions presentation
annapureddyn
 
PDF
Chapter 1 Introduction to CV and IP Lecture Note.pdf
Getnet Tigabie Askale -(GM)
 
PDF
DevOps & Developer Experience Summer BBQ
AUGNYC
 
PDF
REPORT: Heating appliances market in Poland 2024
SPIUG
 
PPTX
How to Build a Scalable Micro-Investing Platform in 2025 - A Founder’s Guide ...
Third Rock Techkno
 
PDF
Unlocking the Future- AI Agents Meet Oracle Database 23ai - AIOUG Yatra 2025.pdf
Sandesh Rao
 
PPTX
ChatGPT's Deck on The Enduring Legacy of Fax Machines
Greg Swan
 
PPTX
Comunidade Salesforce São Paulo - Desmistificando o Omnistudio (Vlocity)
Francisco Vieira Júnior
 
PDF
The Evolution of KM Roles (Presented at Knowledge Summit Dublin 2025)
Enterprise Knowledge
 
PPTX
New ThousandEyes Product Innovations: Cisco Live June 2025
ThousandEyes
 
NewMind AI Weekly Chronicles - July'25 - Week IV
NewMind AI
 
Stamford - Community User Group Leaders_ Agentblazer Status, AI Sustainabilit...
Amol Dixit
 
Revolutionize Operations with Intelligent IoT Monitoring and Control
Rejig Digital
 
cloud computing vai.pptx for the project
vaibhavdobariyal79
 
Presentation about Hardware and Software in Computer
snehamodhawadiya
 
A Day in the Life of Location Data - Turning Where into How.pdf
Precisely
 
L2 Rules of Netiquette in Empowerment technology
Archibal2
 
Using Anchore and DefectDojo to Stand Up Your DevSecOps Function
Anchore
 
This slide provides an overview Technology
mineshkharadi333
 
Building High-Performance Oracle Teams: Strategic Staffing for Database Manag...
SMACT Works
 
Coupa-Overview _Assumptions presentation
annapureddyn
 
Chapter 1 Introduction to CV and IP Lecture Note.pdf
Getnet Tigabie Askale -(GM)
 
DevOps & Developer Experience Summer BBQ
AUGNYC
 
REPORT: Heating appliances market in Poland 2024
SPIUG
 
How to Build a Scalable Micro-Investing Platform in 2025 - A Founder’s Guide ...
Third Rock Techkno
 
Unlocking the Future- AI Agents Meet Oracle Database 23ai - AIOUG Yatra 2025.pdf
Sandesh Rao
 
ChatGPT's Deck on The Enduring Legacy of Fax Machines
Greg Swan
 
Comunidade Salesforce São Paulo - Desmistificando o Omnistudio (Vlocity)
Francisco Vieira Júnior
 
The Evolution of KM Roles (Presented at Knowledge Summit Dublin 2025)
Enterprise Knowledge
 
New ThousandEyes Product Innovations: Cisco Live June 2025
ThousandEyes
 

Introduction to Angular 2

  • 1. INTRO TO ANGULAR 2 & COMPARISION WITH ANGULAR 1.X NIKHIL KUMAR | SOFTWARE CONSULTANT Knoldus Software LLP
  • 2. AGENDA l INTRODUCTION to NG 2.0 & CONCEPTS l WHY NEW VERSION ? l MAJOR KEY FEATURES l PROBLEMS IN 1.X & SOLUTIONS IN 2.0 l WEB COMPONENTS l MIGRATION PATH TO ANGULAR 2
  • 3. AngularJS 1.3 is by far the best version of Angular available today. It was just released a few weeks ago. It's chock full of bug fixes, feature enhancements and performance improvements. HISTORY & STABILITY
  • 4. Why Angular 2 A framework that cannot work with Web Components, bogs down on mobile or continues to push its own module and class API against the standards, is not going to last long. The Angular team's answer to these problems is a new version: Angular 2.0. It is essentially a re-imagining of AngularJS for the modern web, taking into account everything that has been learned over the last five years.
  • 6. Web Components? Web Components are on the horizon. The term Web Components usually refers to a collection of four related W3C specifications: Custom Elements - Enables the extension of HTML through custom tags. HTML Imports - Enables packaging of various resources (HTML, CSS, JS, etc.). Template Element - Enables the inclusion of inert HTML in a document. Shadow DOM - Enables encapsulation of DOM and CSS.
  • 7. ES ? ECMA Script specification is a standardardized specification of a scripting language developed by Brendan of Netscape, initially it was named Mocha, later LiveScript and finally JavaScript. In 1995 Sun & Netscape annnouced Javascript.
  • 8. Directives In Angular 2.0 there will be three kinds of directives: Component Directives – These will create reusable components by encapsulating logic in JavaScript, HTML or an optional CSS style sheet. Decorator Directives – These directives will be used to decorate elements (for example adding a tooltip, or showing/hiding elements using ng-show/ng-hide). Template Directives – These will turn HTML into a reusable template. The instantiating of the template and its insertion into the DOM can be fully controlled by the directive author. Examples include ng-if and ng- repeat.
  • 9. Structure Should/May be link: root-app-folder ├── index.html ├── scripts │ ├── controllers │ │ └── main.js │ │ └── ... │ ├── directives │ │ └── myDirective.js │ │ └── ... │ ├── filters │ │ └── myFilter.js │ │ └── ... │ ├── services │ │ └── myService.js │ │ └── ... │ ├── vendor │ │ ├── angular.js │ │ ├── angular.min.js │ │ ├── es5-shim.min.js │ │ └── json3.min.js │ └── app.js ├── styles │ └── ... └── views ├── main.html └── ...
  • 10. Key Features ● Mobile First ● Digest cycle ● Future Ready ● Speed & Performance ● Simple & Expressive ● Hierarchical Dependency Injection ● Support for Web Components
  • 11. Differences with features 1- no digest cycle finished event 2- How Faster 3- Improved dependency injection 4- Directives Strategy etc
  • 12. No digest cycle finished event $scope.$watch, $scope.$apply, $timeout. $scope.$watch('variable',function(newValue,oldValue){   }); because such event might trigger further changes that kept the digest cycle going. we had to reason about when to call $scope.apply or $scope.digest, which was not always straightforward on occasion we had to call $timeout to let Angular finish its digest cycle and do some operation only when the DOM is stable
  • 13. No digest cycle finished event... Problems: Its not clear which watchers will be fired and in which order, or how many times the order of the model updates is hard to reason about and anticipate the digest cycle can run multiple times(thats why no digest life cycle finished event) which is time consuming Solution: One of the first steps that the Angular team took in the direction of Angular 2, was to extract from the Angular code base the mechanism of patching all asynchronous interaction points, and made it reusable.
  • 14. SOLUTION... $scope.$watch, $scope.$apply, $timeout. No more. Whew! Using these was part of the reason Angular 1.x had such a huge learning curve. Zone.js helps Angular to do change detection automatically. This sounds similar to React's reconciliation diffing algorithm. element.addEventListener('keyup', function () {     console.log('Key pressed.'); }); });
  • 15. WHY ANGULAR 2.0 IS FASTER 1- Faster checking of a single binding 2- Avoid scanning parts of the component tree
  • 16. Improved dependency injection Problem in Angluar 1.x Angular 1 has a global pool of objects:
  • 17. Improved dependency injection Solution in Angluar 2 In Angular 2 there will be only one DI mechanism: constructor injection by type. The fact that there is only one mechanism makes it easier to learn. Also the dependency injector is hierarchical, meaning that at different points of the component tree it's possible to have different implementations of the same type.
  • 18. Ng-directives Components in the HTML are broken up into two types: (events) & [properties]. 1.x 2.0 ng-click (click) (dbl-click) ng-keyup (keyup) (events) refer to user initiated actions. [properties] now link directly into the DOM properties. 1.x 2.0 ng-hide [class:hidden] ng-checked [checked]
  • 19. *foreach !foreach is the proposed replacement for ng-repeat. <ul> <li *foreach="#item in itemService.items"></li> </ul> #item Items prefixed with a # can bind directly in the html. No more ng-model. <input type="text" #userName />
  • 20. Migration Path to angular 2 The new Angular 2 router is being backported to Angular 1, and will allow the same application to have both Angular 1 and Angular 2 routes. It will be possible to mix Angular 1 and Angular 2 components in the same application It will be possible to inject services across framework versions. Data binding will work accross versions as the two change detection mechanisms will be integrated.
  • 21. Component...? To build an Angular 2 application you define a set of components, for every UI element, screen, and route. An application will always have a root component that contains all other components. In other words, every Angular 2 application will have a component tree
  • 22. Component... @Component({ selector: 'talk-cmp', properties: ['talk'], events: ['rate'] }) @View({ directives: [FormattedRating, WatchButton, RateButton], templateUrl: 'talk_cmp.html' }) Talk_cmp.html {{talk.title}} {{talk.speaker}}

Editor's Notes

  • #4: GOOGLE APPS 1600 WAS ONLY FOR DESIGNERS Ng2.0 is not stable now
  • #7: By combining these four capabilities web developers can create declarative components (Custom Elements) which are fully encapsulated (Shadow DOM). These components can describe their own views (Template Element) and can be easily packaged for distribution to other developers (HTML Imports). When these specifications become available in all major browsers, we are likely to see developer creativity explode as many endeavor to create reusable components to solve common problems or address deficiencies in the standard HTML toolkit
  • #10: This is the typical folder layout that I recommend: The best advice about huge apps is not to make them. Write small, focused, modular parts, and progressively combine them into bigger things to make your app. For larger organizational project, you can checout the seed angular project: https://github.com/angular-app/angular-app As you add more files, it might make sense to create subdirectories to further organize controllers and services. For instance, I often find myself making a models directory inside of services. My rule of thumb is to only further sort files into directories if there is some rational hierarchy by which you can organize the files.
  • #11: Angular&amp;apos;s modular library design and mobile-specific routing help keep your app&amp;apos;s code lean, so users on low-bandwidth networks don&amp;apos;t need to wait. Other mobile-first features include first-class support for touch event gestures, tuning for performance and low-memory usage on mobile platforms, and material design UI components with responsive, cross-device support.
  • #12: Note that every single Binding often has a corresponding Key object which is internally created and maintained by Guice. Providers, if any, which are associated with the Injector can be retrieved by the following method. Provider provider = injector.getProvider(SomeType.class)
  • #13: DIRTY CHECKING 2 WAY DATA BINDING $digest (calls watch at frequest intervals of time) $watch is angular method, for dirty checking. Any variable or expression assigned in $scope automatically sets up a $watchExpression in angular. You can create a watch express yourself as well So assigning a variable to $scope or using directives like ng-if, ng-show, ng-repeat etc all create watches in angular scope automatically. e.g $scope.text = &amp;apos;&amp;apos;; creates a $watch for ‘text’ automatically in angular. $apply $apply() is a angular method, internally invokes $digest.
  • #16: The mechanism to check a single binding was optimized to allow the Javascript VM to optimize that code into native code via just-in-time compilation. Instead of scanning recursively a tree of objects, a function is created at Angular startup to see if the binding has changed. This binding-checking function looks like a function that we would write by hand to test for changes and it can be easily optimized away by the VM. Dont chck immutable 1- make the model an Observable: 2- make the model immutable, using for example Facebook&amp;apos;s immutable.js.
  • #17: In Angular 1, the Angular modules are mostly dependency injection containers that group related functionality. Problem The problem is, let&amp;apos;s say we lazy load a second backendService with a completely different implementation: it would overwrite the first one! There is currently no way to have two services with the same name but different implementations, which prevents lazy-loading from being implemented in Angular 1 in a safe way . Types of di in ng 1 in the link function by position in the directive definition by name in the controller function by name, etc.
  • #18: The idea behind dependency injection is very simple. If you have a component that depends on a service. You do not create that service yourself. Instead, you request one in the constructor, and the framework will provide you one. By doing so you can depend on interfaces rather than concrete types. This leads to more decoupled code, which enables testability, and other great things. Solution: If a component does not have a dependency defined, it will delegate the lookup to it&amp;apos;s parent injector and so forth. This sets the ground for providing native lazy-loading support in Angular 2.
  • #19: The mechanism to check a single binding was optimized to allow the Javascript VM to optimize that code into native code via just-in-time compilation. Instead of scanning recursively a tree of objects, a function is created at Angular startup to see if the binding has changed. This binding-checking function looks like a function that we would write by hand to test for changes and it can be easily optimized away by the VM. Dont chck immutable 1- make the model an Observable: 2- make the model immutable, using for example Facebook&amp;apos;s immutable.js.
  • #21: One of the goals of Angular 2 is to provide a clear migration path from Angular 1. This will only become clear when Angular 2 is near it&amp;apos;s initial release, but for now the following is foreseen in the ng-upgrade project:
  • #22: Application is the root component. The Filters component has the speaker input and the filter button. TalkList is the list you see at the bottom. And TalkCmp is an item in that list. A component is a directive with a view. But you can still write decorator-style directives, which do not have views. Components are fundamental building blocks of Angular 2 applications. They have well-defined inputs and outputs. They have well-defined lifecycle. They are self-describing.
  • #23: Application is the root component. The Filters component has the speaker input and the filter button. TalkList is the list you see at the bottom. And TalkCmp is an item in that list. A component is a directive with a view. But you can still write decorator-style directives, which do not have views. Components are fundamental building blocks of Angular 2 applications. They have well-defined inputs and outputs. They have well-defined lifecycle. They are self-describing.