SlideShare a Scribd company logo
1 of 19
Download to read offline
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

More Related Content

What's hot

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
 

What's hot (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
 

Viewers also liked (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 to Angular basicschat

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

Similar to 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
 

Recently uploaded

Finding Java's Hidden Performance Traps @ DevoxxUK 2024
Finding Java's Hidden Performance Traps @ DevoxxUK 2024Finding Java's Hidden Performance Traps @ DevoxxUK 2024
Finding Java's Hidden Performance Traps @ DevoxxUK 2024
Victor Rentea
 

Recently uploaded (20)

Apidays New York 2024 - The value of a flexible API Management solution for O...
Apidays New York 2024 - The value of a flexible API Management solution for O...Apidays New York 2024 - The value of a flexible API Management solution for O...
Apidays New York 2024 - The value of a flexible API Management solution for O...
 
DEV meet-up UiPath Document Understanding May 7 2024 Amsterdam
DEV meet-up UiPath Document Understanding May 7 2024 AmsterdamDEV meet-up UiPath Document Understanding May 7 2024 Amsterdam
DEV meet-up UiPath Document Understanding May 7 2024 Amsterdam
 
[BuildWithAI] Introduction to Gemini.pdf
[BuildWithAI] Introduction to Gemini.pdf[BuildWithAI] Introduction to Gemini.pdf
[BuildWithAI] Introduction to Gemini.pdf
 
"I see eyes in my soup": How Delivery Hero implemented the safety system for ...
"I see eyes in my soup": How Delivery Hero implemented the safety system for ..."I see eyes in my soup": How Delivery Hero implemented the safety system for ...
"I see eyes in my soup": How Delivery Hero implemented the safety system for ...
 
CNIC Information System with Pakdata Cf In Pakistan
CNIC Information System with Pakdata Cf In PakistanCNIC Information System with Pakdata Cf In Pakistan
CNIC Information System with Pakdata Cf In Pakistan
 
Strategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
Strategize a Smooth Tenant-to-tenant Migration and Copilot TakeoffStrategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
Strategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
 
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost Saving
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost SavingRepurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost Saving
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost Saving
 
EMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWER
EMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWEREMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWER
EMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWER
 
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
 
Biography Of Angeliki Cooney | Senior Vice President Life Sciences | Albany, ...
Biography Of Angeliki Cooney | Senior Vice President Life Sciences | Albany, ...Biography Of Angeliki Cooney | Senior Vice President Life Sciences | Albany, ...
Biography Of Angeliki Cooney | Senior Vice President Life Sciences | Albany, ...
 
FWD Group - Insurer Innovation Award 2024
FWD Group - Insurer Innovation Award 2024FWD Group - Insurer Innovation Award 2024
FWD Group - Insurer Innovation Award 2024
 
Apidays New York 2024 - APIs in 2030: The Risk of Technological Sleepwalk by ...
Apidays New York 2024 - APIs in 2030: The Risk of Technological Sleepwalk by ...Apidays New York 2024 - APIs in 2030: The Risk of Technological Sleepwalk by ...
Apidays New York 2024 - APIs in 2030: The Risk of Technological Sleepwalk by ...
 
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
 
WSO2's API Vision: Unifying Control, Empowering Developers
WSO2's API Vision: Unifying Control, Empowering DevelopersWSO2's API Vision: Unifying Control, Empowering Developers
WSO2's API Vision: Unifying Control, Empowering Developers
 
MINDCTI Revenue Release Quarter One 2024
MINDCTI Revenue Release Quarter One 2024MINDCTI Revenue Release Quarter One 2024
MINDCTI Revenue Release Quarter One 2024
 
ICT role in 21st century education and its challenges
ICT role in 21st century education and its challengesICT role in 21st century education and its challenges
ICT role in 21st century education and its challenges
 
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
 
MS Copilot expands with MS Graph connectors
MS Copilot expands with MS Graph connectorsMS Copilot expands with MS Graph connectors
MS Copilot expands with MS Graph connectors
 
Finding Java's Hidden Performance Traps @ DevoxxUK 2024
Finding Java's Hidden Performance Traps @ DevoxxUK 2024Finding Java's Hidden Performance Traps @ DevoxxUK 2024
Finding Java's Hidden Performance Traps @ DevoxxUK 2024
 
Exploring Multimodal Embeddings with Milvus
Exploring Multimodal Embeddings with MilvusExploring Multimodal Embeddings with Milvus
Exploring Multimodal Embeddings with Milvus
 

Angular basicschat