SlideShare una empresa de Scribd logo
1 de 19
Descargar para leer sin conexión
Angular.js Basics
●

Modules

●

Routes

●

Controllers

●

Services

●

Templates

●

Directives

●

Events

●

Promises

●

Animation
Modules
●

Your app

●

Adding dependencies
–
–

●

Script tag
Inject

Why modules
–

Reusability

–

Easily include external work
Routes
●

URLs to views

●

Parameters

●

.when

●

.otherwise

●

Options
–

Template/templateUrl

–

Controller

–

resolve

–

Other parameters (anything you want)

Check out Routing1
Services
●

Angular services are singletons objects or functions that carry out
specific tasks common to web apps
–
–

Lazily executed

–
●

Singleton
Available app-wide via dependency injection

Types of services
–

Value

–

Service / Factory | create the service object

–

Provider | configurable and creates the service object

Check out Services
Services
●

Built-in service
–
–

●

Start with $
$http, $resource, $q, $swipe etc....

Build service whenever you
–

Want to execute the same tasks from several places in the app

–

Want to keep app states

–

Need app-wide accessible data (states, constants, etc)

–

Need to communicate with an external API

–

Need to handle caching

Check out Provider
Services
Levels of abstraction
Module

Service

btford.socket-io

socket

ChatFrontendApp

Chatsocket

Chatservice

Abstraction

●
Controllers
●

Presentation logic

●

Two way data binding

●

$scope is the glue

●

$scope inheritance and $rootScope

●

Controller as syntax
Controllers – Scope structure
Controllers
●

Event listening
–

$emit

–

$broadcast

–

$on
●

●

stopPropagation

$watch
–

Without true as second parameter

–

With true as second parameter

Check out Presentation
Controllers – Advices
●

What should be there
–

Presentation logic

–

Arguably some logic such as filtering / ordering

–

Calls to services

–

Event listening and variable watches
Controllers – Advices
●

What you should remember
–

Controllers are created
●

every time a user reaches a URL (ng-view directive)

●

every time a DOM element with ng-controller is created

–

They do not allow persistence of state or data (use services for that)

–

They have an inheritance pattern that follows the DOM structure

–

$rootScope is always available but should not be overcrowded with “global” functions or vars

–

“Controller as” can be used for good readability but not atm replace $scope for certain features
Controllers – Advices
●

Suggested code flow
–
–

Define private functions and public functions

–

Set up listeners

–
●

Define variables

Call services and functions last

What you should (almost) never see in a controller
–

$http, $resource, $cacheFactory => all belong in services

–

$rootScope.$on (event listeners would be added many times to the root scope)

–

String literals for event names => Probably belong in a service

–

DOM manipulation
Templates
●

Presentation layer

●

HTML

●

Bound to model via
–

$scope

–

Controller as

Check out Presentation
Directives
●

Directives are a way to teach HTML new tricks

●

Angular directives
–
–

Styling: ngShow, ngHide, ngClass, ngStyle

–
●

DOM control: ngIf, ngSwitch, ngRepeat
Events: ngClick, ngFocus, ngKeypress, ngCopy

Other directives (e.g. from UI Bootstrap)
–

Accordion

–

Datepicker

–

Tabs
Directives
●

Using directives
–

Attribute

–

Tag

–

Comment

–

Class

●

Declarative

●

Watch out:
–

No error if fail to include directive (ignored)

Check out Directives
Directives
●

Naming: in HTML / in Javascript

●

Building directives
–

Restriction (AECM)

–

Template

–

Link function

Check out Directives2

●

Scope

●

Element

●

Attributes

–

Scope

–

Transclusion

Check out Directives3
Directives
●

Compile
–

Only called once for each instance

–

No scope

–

Performance

–

Return a link function or a pre/post link functions

●

Replace

●

Warning: this is equal to window inside a directive
Animation
●

Changes in 1.2
–

By class – no more ngAnimate

–

Check out Animation

$animate service

●

http://www.yearofmoo.com/2013/08/remastered-animation-in-angularjs-1-2.html

●

http://dl.dropboxusercontent.com/u/24421764/Website/Projects/ngAnimate/index.html

●

●

●

Https://github.com/matiboy/AngularBasicsChat.git

Más contenido relacionado

La actualidad más candente

Ch. 9 jsp standard tag library
Ch. 9 jsp standard tag libraryCh. 9 jsp standard tag library
Ch. 9 jsp standard tag library
Manolis Vavalis
 
Shootout! template engines on the jvm
Shootout! template engines on the jvmShootout! template engines on the jvm
Shootout! template engines on the jvm
NLJUG
 

La actualidad más candente (20)

Moving From AngularJS to Angular 2
Moving From AngularJS to  Angular 2 Moving From AngularJS to  Angular 2
Moving From AngularJS to Angular 2
 
How angularjs saves rails
How angularjs saves railsHow angularjs saves rails
How angularjs saves rails
 
JavaScript operators
JavaScript operatorsJavaScript operators
JavaScript operators
 
Web development basics (Part-3)
Web development basics (Part-3)Web development basics (Part-3)
Web development basics (Part-3)
 
Symfony bundle fo asynchronous job processing
Symfony bundle fo asynchronous job processingSymfony bundle fo asynchronous job processing
Symfony bundle fo asynchronous job processing
 
Ch. 8 script free pages
Ch. 8 script free pagesCh. 8 script free pages
Ch. 8 script free pages
 
Ch. 9 jsp standard tag library
Ch. 9 jsp standard tag libraryCh. 9 jsp standard tag library
Ch. 9 jsp standard tag library
 
Binary Studio Academy PRO. JS course. Lecture 2. backbone
Binary Studio Academy PRO. JS course. Lecture 2. backboneBinary Studio Academy PRO. JS course. Lecture 2. backbone
Binary Studio Academy PRO. JS course. Lecture 2. backbone
 
Web development basics (Part-5)
Web development basics (Part-5)Web development basics (Part-5)
Web development basics (Part-5)
 
AngularJS Basics and Best Practices - CC FE &UX
AngularJS Basics and Best Practices - CC FE &UXAngularJS Basics and Best Practices - CC FE &UX
AngularJS Basics and Best Practices - CC FE &UX
 
Workshop 16: EmberJS Parte I
Workshop 16: EmberJS Parte IWorkshop 16: EmberJS Parte I
Workshop 16: EmberJS Parte I
 
Being a jsp
Being a jsp     Being a jsp
Being a jsp
 
Rails course day 6
Rails course day 6Rails course day 6
Rails course day 6
 
Workshop 9: BackboneJS y patrones MVC
Workshop 9: BackboneJS y patrones MVCWorkshop 9: BackboneJS y patrones MVC
Workshop 9: BackboneJS y patrones MVC
 
Ruby on Rails + AngularJS + Twitter Bootstrap
Ruby on Rails + AngularJS + Twitter BootstrapRuby on Rails + AngularJS + Twitter Bootstrap
Ruby on Rails + AngularJS + Twitter Bootstrap
 
AngularJS
AngularJSAngularJS
AngularJS
 
Shootout! template engines on the jvm
Shootout! template engines on the jvmShootout! template engines on the jvm
Shootout! template engines on the jvm
 
Angularjs architecture
Angularjs architectureAngularjs architecture
Angularjs architecture
 
Leveraging the Chaos tool suite for module development
Leveraging the Chaos tool suite  for module developmentLeveraging the Chaos tool suite  for module development
Leveraging the Chaos tool suite for module development
 
Ruby on Rails - UNISO
Ruby on Rails - UNISORuby on Rails - UNISO
Ruby on Rails - UNISO
 

Destacado (8)

Au meilleur iphone offres
Au meilleur  iphone offresAu meilleur  iphone offres
Au meilleur iphone offres
 
Eop 2.7 pac pgma anual mensualizado de caja
Eop 2.7 pac pgma anual mensualizado de cajaEop 2.7 pac pgma anual mensualizado de caja
Eop 2.7 pac pgma anual mensualizado de caja
 
Heterokont
HeterokontHeterokont
Heterokont
 
Double Page Spread Presentation
Double Page Spread PresentationDouble Page Spread Presentation
Double Page Spread Presentation
 
Régime par répartition iphone offres
Régime par répartition iphone offresRégime par répartition iphone offres
Régime par répartition iphone offres
 
News World
News WorldNews World
News World
 
Mary Did You Know
Mary Did You KnowMary Did You Know
Mary Did You Know
 
Iphone payer par mois
Iphone payer par moisIphone payer par mois
Iphone payer par mois
 

Similar a Angular basicschat

MVC & SQL_In_1_Hour
MVC & SQL_In_1_HourMVC & SQL_In_1_Hour
MVC & SQL_In_1_Hour
Dilip Patel
 

Similar a Angular basicschat (20)

Angular presentation
Angular presentationAngular presentation
Angular presentation
 
Introduction to AngularJs
Introduction to AngularJsIntroduction to AngularJs
Introduction to AngularJs
 
Angular js 1.0-fundamentals
Angular js 1.0-fundamentalsAngular js 1.0-fundamentals
Angular js 1.0-fundamentals
 
End to-End SPA Development Using ASP.NET and AngularJS
End to-End SPA Development Using ASP.NET and AngularJSEnd to-End SPA Development Using ASP.NET and AngularJS
End to-End SPA Development Using ASP.NET and AngularJS
 
Getting started with angular js
Getting started with angular jsGetting started with angular js
Getting started with angular js
 
AngularJS Workshop
AngularJS WorkshopAngularJS Workshop
AngularJS Workshop
 
Knolx session
Knolx sessionKnolx session
Knolx session
 
MVC & SQL_In_1_Hour
MVC & SQL_In_1_HourMVC & SQL_In_1_Hour
MVC & SQL_In_1_Hour
 
Your First Scala Web Application using Play 2.1
Your First Scala Web Application using Play 2.1Your First Scala Web Application using Play 2.1
Your First Scala Web Application using Play 2.1
 
Angular workshop - Full Development Guide
Angular workshop - Full Development GuideAngular workshop - Full Development Guide
Angular workshop - Full Development Guide
 
Angular patterns
Angular patternsAngular patterns
Angular patterns
 
Creating a custom API for a headless Drupal
Creating a custom API for a headless DrupalCreating a custom API for a headless Drupal
Creating a custom API for a headless Drupal
 
Airflow presentation
Airflow presentationAirflow presentation
Airflow presentation
 
Workshop 14: AngularJS Parte III
Workshop 14: AngularJS Parte IIIWorkshop 14: AngularJS Parte III
Workshop 14: AngularJS Parte III
 
Introduction to AngularJS
Introduction to AngularJSIntroduction to AngularJS
Introduction to AngularJS
 
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
 
Getting started with angular js
Getting started with angular jsGetting started with angular js
Getting started with angular js
 
Deploying Perl apps on dotCloud
Deploying Perl apps on dotCloudDeploying Perl apps on dotCloud
Deploying Perl apps on dotCloud
 
OSGi and Cloud Computing - David Bosschaert
OSGi and Cloud Computing - David BosschaertOSGi and Cloud Computing - David Bosschaert
OSGi and Cloud Computing - David Bosschaert
 
Angular Intermediate
Angular IntermediateAngular Intermediate
Angular Intermediate
 

Último

Histor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slideHistor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slide
vu2urc
 
Artificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and MythsArtificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and Myths
Joaquim Jorge
 

Último (20)

[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdf[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdf
 
How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected Worker
 
Tata AIG General Insurance Company - Insurer Innovation Award 2024
Tata AIG General Insurance Company - Insurer Innovation Award 2024Tata AIG General Insurance Company - Insurer Innovation Award 2024
Tata AIG General Insurance Company - Insurer Innovation Award 2024
 
Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024
 
A Year of the Servo Reboot: Where Are We Now?
A Year of the Servo Reboot: Where Are We Now?A Year of the Servo Reboot: Where Are We Now?
A Year of the Servo Reboot: Where Are We Now?
 
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, AdobeApidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
 
Driving Behavioral Change for Information Management through Data-Driven Gree...
Driving Behavioral Change for Information Management through Data-Driven Gree...Driving Behavioral Change for Information Management through Data-Driven Gree...
Driving Behavioral Change for Information Management through Data-Driven Gree...
 
GenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day PresentationGenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day Presentation
 
Boost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivityBoost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivity
 
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time AutomationFrom Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
 
Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024
 
Histor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slideHistor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slide
 
Developing An App To Navigate The Roads of Brazil
Developing An App To Navigate The Roads of BrazilDeveloping An App To Navigate The Roads of Brazil
Developing An App To Navigate The Roads of Brazil
 
Partners Life - Insurer Innovation Award 2024
Partners Life - Insurer Innovation Award 2024Partners Life - Insurer Innovation Award 2024
Partners Life - Insurer Innovation Award 2024
 
presentation ICT roal in 21st century education
presentation ICT roal in 21st century educationpresentation ICT roal in 21st century education
presentation ICT roal in 21st century education
 
TrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
TrustArc Webinar - Unlock the Power of AI-Driven Data DiscoveryTrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
TrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
 
Data Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt RobisonData Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt Robison
 
AWS Community Day CPH - Three problems of Terraform
AWS Community Day CPH - Three problems of TerraformAWS Community Day CPH - Three problems of Terraform
AWS Community Day CPH - Three problems of Terraform
 
Understanding Discord NSFW Servers A Guide for Responsible Users.pdf
Understanding Discord NSFW Servers A Guide for Responsible Users.pdfUnderstanding Discord NSFW Servers A Guide for Responsible Users.pdf
Understanding Discord NSFW Servers A Guide for Responsible Users.pdf
 
Artificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and MythsArtificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and Myths
 

Angular basicschat