SlideShare a Scribd company logo
1 of 33
Introduction to SPA
Riki Pribadi
Riki Pribadi
@flakeware
Python Developer
Source Code Example:
https://github.com/rpribadi/example-spa-angular
I Hate JavaScript
So what is AngularJS?
Just another jQuery?
At some point, yes...but....
It's more than just that!
It's something bigger!
It's a framework!
SPA!
SPA? This SPA?
Oh, you mean this SPA?
So, what is SPA?
Singlepageappbook.com
"Single page apps are distinguished by their
ability to redraw any part of the UI without
requiring a server roundtrip to retrieve HTML.
This is achieved by separating the data from
the presentation of data by having a model
layer that handles data and a view layer that
reads from the models."
Why do we need SPA?
Singlepageappbook.com
"The main reason is that they allow us to offer a
more-native-app-like experience to the user."
More-Native-App-Like Experience?
Sadly speaking, yes!
Just 'more'...it's not really native.
So, IMHO...
If GMAIL (web version) is not a SPA, will it
really matter?
If you wait 2 seconds longer, will it really
matter?
So, IMHO...
It's harder than the usual web apps
It's duplicating validation step, but I guess it's
quite normal nowdays
So, IMHO...
Unless you have a damn good reason to build it
as SPA, maybe, just maybe......deep down
inside, you are a masochist developer
OR
We just love to challenge ourselves!
What does SPA look like?
Notice the URLs!
https://mail.google.com/mail/u/0/#inbox
https://mail.google.com/mail/u/0/#drafts
https://mail.google.
com/mail/u/0/#inbox/13f93d5835e1d04a
...
OK, so where should I start?
AngularJS Home Page
http://angularjs.org
That sounds nice!
And here comes the famous Hello World
example!
Followed by simple TODO app!
And suddenly they talk about modules,
directive, dependency injection, service,
factory....
I was like...
Rule of thumb
Don't be like,
"A solution tries to find a problem"
Be like,
"A problem tries to find a solution"
So what is the problem (goal)?
I want to create a SPA where:
1. I can manage my todo list
2. I can manage category of my todo list
3. Normally, I only need to see the dashboard
page where all my todo list is group by category
and I can check/uncheck the list items
OK, let's set up the project
You can manually setup your project folder
OR
You can use available project templates out
there:
- angular-seed
- ng-boilerplate
The Angular Way
I use angular-seed
Identify requirements
I will need:
- dashboard page
- CRUD page for category
- CRUD page for todo item
New Project Layout
Main Page (index.html)
<!doctype html>
<html lang="en" ng-app="myApp">
<body>
<article ng-view></article>
<footer>Let's learn AngularJS</footer>
<script src="lib/angular/angular.js"></script>
<script src="js/app.js"></script>
<script src="js/controllers.js"></script>
<script src="js/organize/category/controllers.js"></script>
<script src="js/organize/category/services.js"></script>
<script src="js/organize/todo/controllers.js"></script>
<script src="js/organize/todo/services.js"></script>
</body>
</html>
Index Category
The URL Conf: js/app.js
angular.module('myApp', ['CategoryModule.controllers']).
config(['$routeProvider', function($routeProvider) {
$routeProvider.when(
'/organize/category/index',
{
templateUrl: 'partials/organize/category/index.html',
controller: 'CategoryIndexController'
});
}]);
partials/organize/category/index.html
<h1>Category List</h1>
<table class="table">
<tr>
<th>#ID</th>
<th>Category</th>
<th>Action</th>
</tr>
<tr ng-repeat="(id, category) in categories">
<td>{{ id }}</td>
<td>{{ category.name }}</td>
<td>
<a href="#/organize/category/save/{{ id }}">Edit</a>
<a ng-click="del(id)">Delete</a>
</td>
</tr>
</table>
js/organize/category/controllers.py
angular.module('CategoryModule.controllers', ['CategoryModule.services']).
controller('CategoryIndexController', ['$scope', '$$category', function($scope,
$$category) {
$scope.categories = $$category.all();
$scope.del = function(id) {
$$category.del(id);
$scope.flash = "Category Deleted.";
};
}])
...
js/organize/category/services.js
angular.module('CategoryModule.services', []).factory('$$category', [function() {
var categories = {};
var latest_id = 1
var factory = {};
factory.all = function() {
return categories;
};
factory.del = function(id) {
if (categories.hasOwnProperty(id)) {
delete categories[id];
return true;
}
return false
};
return factory;
}]);
Why do we need Service?
It's all related to GLOBAL
Global State
Global Function
Global Helper
That's all...

More Related Content

What's hot

Angular.js Talk at the November Meetup of the BerlinJS User Group
Angular.js Talk at the November Meetup of the BerlinJS User GroupAngular.js Talk at the November Meetup of the BerlinJS User Group
Angular.js Talk at the November Meetup of the BerlinJS User Group
Manuel Kießling
 
SlickGrid Touch: Making complex JavaScript widgets work on mobile devices
SlickGrid Touch: Making complex JavaScript widgets work on mobile devicesSlickGrid Touch: Making complex JavaScript widgets work on mobile devices
SlickGrid Touch: Making complex JavaScript widgets work on mobile devices
reebalazs
 
Using WordPress for Rapid Prototyping
Using WordPress for Rapid PrototypingUsing WordPress for Rapid Prototyping
Using WordPress for Rapid Prototyping
Drew Morris
 
jQuery Conference San Diego 2014 - Web Performance
jQuery Conference San Diego 2014 - Web PerformancejQuery Conference San Diego 2014 - Web Performance
jQuery Conference San Diego 2014 - Web Performance
dmethvin
 

What's hot (20)

GDG Atlanta - Angular.js Demo and Workshop
GDG Atlanta - Angular.js Demo and WorkshopGDG Atlanta - Angular.js Demo and Workshop
GDG Atlanta - Angular.js Demo and Workshop
 
AngularJs Basic Concept
AngularJs Basic ConceptAngularJs Basic Concept
AngularJs Basic Concept
 
JS Framework Comparison - An infographic
JS Framework Comparison - An infographicJS Framework Comparison - An infographic
JS Framework Comparison - An infographic
 
SGCE 2012 Lightning Talk-Single Page Interface
SGCE 2012 Lightning Talk-Single Page InterfaceSGCE 2012 Lightning Talk-Single Page Interface
SGCE 2012 Lightning Talk-Single Page Interface
 
Get satrted angular js
Get satrted angular jsGet satrted angular js
Get satrted angular js
 
Angular.js Talk at the November Meetup of the BerlinJS User Group
Angular.js Talk at the November Meetup of the BerlinJS User GroupAngular.js Talk at the November Meetup of the BerlinJS User Group
Angular.js Talk at the November Meetup of the BerlinJS User Group
 
SlickGrid Touch: Making complex JavaScript widgets work on mobile devices
SlickGrid Touch: Making complex JavaScript widgets work on mobile devicesSlickGrid Touch: Making complex JavaScript widgets work on mobile devices
SlickGrid Touch: Making complex JavaScript widgets work on mobile devices
 
Wulin kungfu final
Wulin kungfu finalWulin kungfu final
Wulin kungfu final
 
Using WordPress for Rapid Prototyping
Using WordPress for Rapid PrototypingUsing WordPress for Rapid Prototyping
Using WordPress for Rapid Prototyping
 
The Onion
The OnionThe Onion
The Onion
 
jQuery Conference Austin Sept 2013
jQuery Conference Austin Sept 2013jQuery Conference Austin Sept 2013
jQuery Conference Austin Sept 2013
 
[Srijan Wednesday Webinars] Developing Large Scale Applications in AngularJS
[Srijan Wednesday Webinars] Developing Large Scale Applications in AngularJS[Srijan Wednesday Webinars] Developing Large Scale Applications in AngularJS
[Srijan Wednesday Webinars] Developing Large Scale Applications in AngularJS
 
Node PDX: Intro to Sails.js
Node PDX: Intro to Sails.jsNode PDX: Intro to Sails.js
Node PDX: Intro to Sails.js
 
SxSW 2015
SxSW 2015SxSW 2015
SxSW 2015
 
Rapid Prototyping with WordPress Page Builders - WordCamp Asheville 2016 - an...
Rapid Prototyping with WordPress Page Builders - WordCamp Asheville 2016 - an...Rapid Prototyping with WordPress Page Builders - WordCamp Asheville 2016 - an...
Rapid Prototyping with WordPress Page Builders - WordCamp Asheville 2016 - an...
 
Angularjs Basics
Angularjs BasicsAngularjs Basics
Angularjs Basics
 
Choosing a JavaScript Framework
Choosing a JavaScript FrameworkChoosing a JavaScript Framework
Choosing a JavaScript Framework
 
jQuery Conference San Diego 2014 - Web Performance
jQuery Conference San Diego 2014 - Web PerformancejQuery Conference San Diego 2014 - Web Performance
jQuery Conference San Diego 2014 - Web Performance
 
Santa Barbara AngularJS intro to 1.3
Santa Barbara AngularJS intro to 1.3Santa Barbara AngularJS intro to 1.3
Santa Barbara AngularJS intro to 1.3
 
jQuery Keynote - Fall 2010
jQuery Keynote - Fall 2010jQuery Keynote - Fall 2010
jQuery Keynote - Fall 2010
 

Viewers also liked

Viewers also liked (16)

AngularJS App In Two Weeks
AngularJS App In Two WeeksAngularJS App In Two Weeks
AngularJS App In Two Weeks
 
Ionic & Cross Platform Teknolojisi
Ionic & Cross Platform TeknolojisiIonic & Cross Platform Teknolojisi
Ionic & Cross Platform Teknolojisi
 
PhoneGap/Cordova ile Mobil Uygulama Geliştirmeye Giriş
PhoneGap/Cordova ile Mobil Uygulama Geliştirmeye GirişPhoneGap/Cordova ile Mobil Uygulama Geliştirmeye Giriş
PhoneGap/Cordova ile Mobil Uygulama Geliştirmeye Giriş
 
Watch and Learn Mobile Learning System in 5 Steps Pilot Project
Watch and Learn Mobile Learning System in 5 Steps Pilot ProjectWatch and Learn Mobile Learning System in 5 Steps Pilot Project
Watch and Learn Mobile Learning System in 5 Steps Pilot Project
 
IPT angular2 typescript SPA 2016
IPT angular2 typescript SPA 2016IPT angular2 typescript SPA 2016
IPT angular2 typescript SPA 2016
 
0 to Angular in 45 Mins
0 to Angular in 45 Mins0 to Angular in 45 Mins
0 to Angular in 45 Mins
 
Single Page Application con Angular 2
Single Page Application con Angular 2Single Page Application con Angular 2
Single Page Application con Angular 2
 
Working with http client rest apis and connection availability check
Working with http client rest apis and connection availability checkWorking with http client rest apis and connection availability check
Working with http client rest apis and connection availability check
 
Uygulama diline karar vermek: HTML5 mi, Native mi yoksa Hibrit uygulama mı?
Uygulama diline karar vermek: HTML5 mi, Native mi yoksa Hibrit uygulama mı?Uygulama diline karar vermek: HTML5 mi, Native mi yoksa Hibrit uygulama mı?
Uygulama diline karar vermek: HTML5 mi, Native mi yoksa Hibrit uygulama mı?
 
Git 101
Git 101Git 101
Git 101
 
Siz değil iş sizi nasıl bulur? GDG İzmir
Siz değil iş sizi nasıl bulur? GDG İzmir Siz değil iş sizi nasıl bulur? GDG İzmir
Siz değil iş sizi nasıl bulur? GDG İzmir
 
Introduction to Angular 2
Introduction to Angular 2Introduction to Angular 2
Introduction to Angular 2
 
Getting Started with Angular 2
Getting Started with Angular 2Getting Started with Angular 2
Getting Started with Angular 2
 
Effective cv writing
Effective cv writingEffective cv writing
Effective cv writing
 
Awesome Words To Use On Your CV
Awesome Words To Use On Your CVAwesome Words To Use On Your CV
Awesome Words To Use On Your CV
 
Building Universal Applications with Angular 2
Building Universal Applications with Angular 2Building Universal Applications with Angular 2
Building Universal Applications with Angular 2
 

Similar to Introduction to SPA with AngularJS

Designing and Implementing a Multiuser Apps Platform
Designing and Implementing a Multiuser Apps PlatformDesigning and Implementing a Multiuser Apps Platform
Designing and Implementing a Multiuser Apps Platform
Apigee | Google Cloud
 
AngularJS for Legacy Apps
AngularJS for Legacy AppsAngularJS for Legacy Apps
AngularJS for Legacy Apps
Peter Drinnan
 
javscript
javscriptjavscript
javscript
rcc1964
 
Future proofing design work with Web components
Future proofing design work with Web componentsFuture proofing design work with Web components
Future proofing design work with Web components
btopro
 

Similar to Introduction to SPA with AngularJS (20)

Reusable Apps
Reusable AppsReusable Apps
Reusable Apps
 
AngularJS 101
AngularJS 101AngularJS 101
AngularJS 101
 
Introduce Django
Introduce DjangoIntroduce Django
Introduce Django
 
Designing and Implementing a Multiuser Apps Platform
Designing and Implementing a Multiuser Apps PlatformDesigning and Implementing a Multiuser Apps Platform
Designing and Implementing a Multiuser Apps Platform
 
Performance and Optmization - a technical talk at Frontend London
Performance and Optmization - a technical talk at Frontend LondonPerformance and Optmization - a technical talk at Frontend London
Performance and Optmization - a technical talk at Frontend London
 
Crash Course in AngularJS + Ionic (Deep dive)
Crash Course in AngularJS + Ionic (Deep dive)Crash Course in AngularJS + Ionic (Deep dive)
Crash Course in AngularJS + Ionic (Deep dive)
 
SharePoint Saturday NYC - SharePoint and jQuery, what I wish I would have kno...
SharePoint Saturday NYC - SharePoint and jQuery, what I wish I would have kno...SharePoint Saturday NYC - SharePoint and jQuery, what I wish I would have kno...
SharePoint Saturday NYC - SharePoint and jQuery, what I wish I would have kno...
 
Advanced Tips & Tricks for using Angular JS
Advanced Tips & Tricks for using Angular JSAdvanced Tips & Tricks for using Angular JS
Advanced Tips & Tricks for using Angular JS
 
Intro to AngularJs
Intro to AngularJsIntro to AngularJs
Intro to AngularJs
 
End-to-end testing with geb
End-to-end testing with gebEnd-to-end testing with geb
End-to-end testing with geb
 
SMX Munich 2018 - Current State of JavaScript SEO
SMX Munich 2018 - Current State of JavaScript SEOSMX Munich 2018 - Current State of JavaScript SEO
SMX Munich 2018 - Current State of JavaScript SEO
 
AngularJS for Legacy Apps
AngularJS for Legacy AppsAngularJS for Legacy Apps
AngularJS for Legacy Apps
 
javscript
javscriptjavscript
javscript
 
Future proofing design work with Web components
Future proofing design work with Web componentsFuture proofing design work with Web components
Future proofing design work with Web components
 
ITB2015 - Crash Course in Ionic + AngularJS
ITB2015 - Crash Course in Ionic + AngularJSITB2015 - Crash Course in Ionic + AngularJS
ITB2015 - Crash Course in Ionic + AngularJS
 
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)
 
Deep crawl the chaotic landscape of JavaScript
Deep crawl the chaotic landscape of JavaScript Deep crawl the chaotic landscape of JavaScript
Deep crawl the chaotic landscape of JavaScript
 
Sync Workitems between multiple Team Projects #vssatpn
Sync Workitems between multiple Team Projects #vssatpnSync Workitems between multiple Team Projects #vssatpn
Sync Workitems between multiple Team Projects #vssatpn
 
React django
React djangoReact django
React django
 
Web driver selenium simplified
Web driver selenium simplifiedWeb driver selenium simplified
Web driver selenium simplified
 

Recently uploaded

IAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI SolutionsIAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI Solutions
Enterprise Knowledge
 
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
 
Artificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and MythsArtificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and Myths
Joaquim Jorge
 

Recently uploaded (20)

IAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI SolutionsIAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI Solutions
 
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
 
How to convert PDF to text with Nanonets
How to convert PDF to text with NanonetsHow to convert PDF to text with Nanonets
How to convert PDF to text with Nanonets
 
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...
 
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
 
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
 
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
 
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
 
Handwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed textsHandwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed texts
 
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
 
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
 
Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024
 
GenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day PresentationGenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day Presentation
 
Automating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps ScriptAutomating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps Script
 
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
 
Artificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and MythsArtificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and Myths
 
Exploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone ProcessorsExploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone Processors
 
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?
 
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
 
A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)
 

Introduction to SPA with AngularJS