SlideShare ist ein Scribd-Unternehmen logo
1 von 19
Downloaden Sie, um offline zu lesen
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

Weitere ähnliche Inhalte

Was ist angesagt?

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
 

Was ist angesagt? (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
 

Andere mochten auch (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
 

Ähnlich wie Angular basicschat

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

Ähnlich wie 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
 

Kürzlich hochgeladen

CNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of ServiceCNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of Service
giselly40
 

Kürzlich hochgeladen (20)

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
 
What Are The Drone Anti-jamming Systems Technology?
What Are The Drone Anti-jamming Systems Technology?What Are The Drone Anti-jamming Systems Technology?
What Are The Drone Anti-jamming Systems Technology?
 
Scaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organizationScaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organization
 
GenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day PresentationGenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day Presentation
 
Boost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdfBoost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdf
 
TrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law DevelopmentsTrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
 
Powerful Google developer tools for immediate impact! (2023-24 C)
Powerful Google developer tools for immediate impact! (2023-24 C)Powerful Google developer tools for immediate impact! (2023-24 C)
Powerful Google developer tools for immediate impact! (2023-24 C)
 
Real Time Object Detection Using Open CV
Real Time Object Detection Using Open CVReal Time Object Detection Using Open CV
Real Time Object Detection Using Open CV
 
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
 
Factors to Consider When Choosing Accounts Payable Services Providers.pptx
Factors to Consider When Choosing Accounts Payable Services Providers.pptxFactors to Consider When Choosing Accounts Payable Services Providers.pptx
Factors to Consider When Choosing Accounts Payable Services Providers.pptx
 
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
 
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
 
CNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of ServiceCNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of Service
 
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
 
[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
 
The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024
 
Breaking the Kubernetes Kill Chain: Host Path Mount
Breaking the Kubernetes Kill Chain: Host Path MountBreaking the Kubernetes Kill Chain: Host Path Mount
Breaking the Kubernetes Kill Chain: Host Path Mount
 
2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...
 
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
 
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
 

Angular basicschat