SlideShare ist ein Scribd-Unternehmen logo
1 von 49
Igor Talevski
Developer @ http://it-labs.com/
2
@TalevskiIgor
Please Mute your
mobile devices
3
General Sponsors
Platinum Sponsors
Silver Sponsors
Gold Sponsors
Bronze Sponsors
4
Introduction
5
Angular learning curve
6
SPA concepts
• SPA works and feels more like an application then a web page.
• SPA separates UI and data, SPA communicates with server only with JSON REST API (Send/Receive
JSON using AJAX)
• Reducing bandwidth usage is also a plus
• SPA can use caching and local storage effectively.
• You can easily fake JSON data communication to test SPA, and you can also easily fake JSON requests
to server to write unit tests.
• Some SPAs don’t require SEO, but for those that do, the solutions aren’t straightforward.
• Analytics is harder to implement
7
Single-Page Applications (SPAs) are Web apps that load a single HTML page
and dynamically update that page as the user interacts with the app.
8
Normal page life circle
9
SPA life circle
Automatic Initialization
• load the module associated with the directive.
• create the application injector
• compile the DOM treating the ngApp directive
as the root of the compilation.
(This allows you to tell it to treat only a portion
of the DOM as an Angular application.)
10
Angular initializes automatically upon DOMContentLoaded event or when the angular.js script
is evaluated if at that time document.readyState is set to 'complete‘.
Manual Initialization
• After the page and all of the code is loaded,
find the root element of your AngularJS
application, which is typically the root of the
document.
• Call angular.bootstrap to compile the element
into an executable, bi-directionally bound
application.
11
If you need to have more control over the initialization process, you can use a manual bootstrapping
method instead. Examples of when you'd need to do this include using script loaders or the need to
perform an operation before Angular compiles a page.
12
Combine with other library
13
Combine with other library
14
Architecture
Folders by type
15
Architecture
Folders by feature
16
17
Architecture
Folders by type
Folders by feature
M I X
Application Structure LIFT Principle
• Make locating your code intuitive, simple and fast.
• When you look at a file you should instantly know what it contains and represents.
• Keep a flat folder structure as long as possible. When you get to 8+ files, begin
considering separation.
• Be DRY, but don't go nuts and sacrifice readability.
18
Structure your app such that you can Locate your code quickly Identify the
code at a glance keep the Flattest structure you can and Try to stay DRY.
19
Module
You can think of a module as a container for the different parts of your app – controllers,
services, filters, directives, etc…
Data Binding
20
Automatic synchronization of data between the model and view
Controllers
Use controllers to:
• Set up the initial state of the $scope object.
• Add behavior to the $scope object.
Do not use controllers to:
• Manipulate DOM — Controllers should contain only business logic.
• Format input — Use angular form controls instead.
• Filter output — Use angular filters instead.
• Share code or state across controllers — Use angular services instead.
• Manage the life-cycle of other components (to create service instances).
21
In Angular, a Controller is defined by a JavaScript constructor function that is used to
augment the Angular Scope.
Nesting controllers
• The root scope
• The MainController scope
• The ChildController scope
• The GrandChildController scope
22
Demo
23
Dependency Injection
24
Dependency Injection (DI) is a software design pattern that deals with how components
get hold of their dependencies.
Dependency Annotation
25
Angular invokes certain functions (like service factories and controllers) via the injector. You need to
annotate these functions so that the injector knows what services to inject into the function.
Inline Array Annotation
Property Annotation
Implicit Annotation
Useful Tools For Developers
26
Yeoman generator for
AngularJS - lets you quickly
set up a project with
sensible defaults and best
practices.
Useful Tools For Developers
27
Useful Tools For Developers
28
• (local server) The actual grunt server
• (jshint) Make sure there are no obvious mistakes
• (jscs) Make sure code styles are up to par
• (clean) Empties folders to start fresh
• (postcss) Add vendor prefixed styles
• (wiredep) Automatically inject Bower components into the app
• (compass) Compiles Sass to CSS and generates necessary files if requested
• (filerev) Renames files for browser caching purposes
• (usemin) Performs rewrites based on filerev and the useminPrepare configuration
• (ngAnnotate) *tries to make the code safe for minification automatically
• (ngTemplate) register your AngularJS templates in the $templateCache
• (livereload) Watches files for changes and runs tasks based on the changed files
• uglify, cssmin, imagemin, svgmin, htmlmin, etc ...
Useful Packages
29
• ng-constant
If you develop a website that uses multiple environments such as development, staging and
production you probably have a configuration file of sorts to handle things like database
settings, mail server credentials, and so on for your backend system.
But how do you handle such variables in the front-end? Specifically, in an AngularJS App?
Directives
• 'A' - only matches attribute name
• 'E' - only matches element name
• 'C' - only matches class name
• 'M' - only matches comment
30
At a high level, directives are markers on a DOM element (such as an attribute, element name,
comment or CSS class) that tell AngularJS's HTML compiler ($compile) to attach a specified behavior to
that DOM element (e.g. via event listeners), or even to transform the DOM element and its children.
Getting data from the server
31
Getting data from the server
32
Getting data from the server
33
• data – {string | Object} – The response body transformed with the transform functions.
• status – {number} – HTTP status code of the response.
• headers – {function([headerName])} – Header getter function.
• config – {Object} – The configuration object that was used to generate the request.
• statusText – {string} – HTTP status text of the response.
Restangular
34
35
Service Repository
36
Usage of Service Repository
37
Same-origin policy
The same-origin policy restricts how a document or script loaded from one origin can
interact with a resource from another origin. It is a critical security mechanism for
isolating potentially malicious documents.
38
HTTP status codes
39
HTTP status codes
40
HTTP status codes
https://httpstatuses.com/
AngularUI Router
41
Routing frameworks for SPAs update the browser's URL as the user nagivates through the app.
JWT
42
JSON Web Tokens are an open, industry standard RFC 7519 method for representing claims
securely between two parties.
Interceptors
43
For purposes of global error handling, authentication, or any kind of synchronous or
asynchronous pre-processing of request or postprocessing of responses, it is desirable to be
able to intercept requests before they are handed to the server and responses before they are
handed over to the application code that initiated these requests.
WebSockets
44
is an advanced technology that makes it possible to open an interactive communication
session between the user's browser and a server.
WebSockets
45
WebSockets
46
Demo
47
Complete the evaluation
and earn the chance to win
prizes in the closing raffle
http://eval.codecamp.mk
48
Questions
Thank you

Weitere ähnliche Inhalte

Was ist angesagt?

Rails Request & Middlewares
Rails Request & MiddlewaresRails Request & Middlewares
Rails Request & MiddlewaresSantosh Wadghule
 
Jakarta EE Recipes
Jakarta EE RecipesJakarta EE Recipes
Jakarta EE RecipesJosh Juneau
 
04 integrate entityframework
04 integrate entityframework04 integrate entityframework
04 integrate entityframeworkErhwen Kuo
 
Advanced SharePoint Web Part Development
Advanced SharePoint Web Part DevelopmentAdvanced SharePoint Web Part Development
Advanced SharePoint Web Part DevelopmentRob Windsor
 
Request-Response Cycle of Ruby on Rails App
Request-Response Cycle of Ruby on Rails AppRequest-Response Cycle of Ruby on Rails App
Request-Response Cycle of Ruby on Rails AppNathalie Steinmetz
 
Learn Ajax here
Learn Ajax hereLearn Ajax here
Learn Ajax herejarnail
 
Creating Modular Test-Driven SPAs with Spring and AngularJS
Creating Modular Test-Driven SPAs with Spring and AngularJSCreating Modular Test-Driven SPAs with Spring and AngularJS
Creating Modular Test-Driven SPAs with Spring and AngularJSGunnar Hillert
 
[2015/2016] Local data storage for web-based mobile apps
[2015/2016] Local data storage for web-based mobile apps[2015/2016] Local data storage for web-based mobile apps
[2015/2016] Local data storage for web-based mobile appsIvano Malavolta
 
Introduction to the SharePoint 2013 REST API
Introduction to the SharePoint 2013 REST APIIntroduction to the SharePoint 2013 REST API
Introduction to the SharePoint 2013 REST APISparkhound Inc.
 
Data Access Options in SharePoint 2010
Data Access Options in SharePoint 2010Data Access Options in SharePoint 2010
Data Access Options in SharePoint 2010Rob Windsor
 
Learn AJAX at ASIT
Learn AJAX at ASITLearn AJAX at ASIT
Learn AJAX at ASITASIT
 
SharePoint 2010 Application Development Overview
SharePoint 2010 Application Development OverviewSharePoint 2010 Application Development Overview
SharePoint 2010 Application Development OverviewRob Windsor
 
Session 35 - Design Patterns
Session 35 - Design PatternsSession 35 - Design Patterns
Session 35 - Design PatternsPawanMM
 
ApacheCon North America 2018: Creating Spark Data Sources
ApacheCon North America 2018: Creating Spark Data SourcesApacheCon North America 2018: Creating Spark Data Sources
ApacheCon North America 2018: Creating Spark Data SourcesJayesh Thakrar
 
Slick – the modern way to access your Data
Slick – the modern way to access your DataSlick – the modern way to access your Data
Slick – the modern way to access your DataJochen Huelss
 
06 integrate elasticsearch
06 integrate elasticsearch06 integrate elasticsearch
06 integrate elasticsearchErhwen Kuo
 

Was ist angesagt? (20)

Rails Request & Middlewares
Rails Request & MiddlewaresRails Request & Middlewares
Rails Request & Middlewares
 
Jakarta EE Recipes
Jakarta EE RecipesJakarta EE Recipes
Jakarta EE Recipes
 
04 integrate entityframework
04 integrate entityframework04 integrate entityframework
04 integrate entityframework
 
LINQ in C#
LINQ in C#LINQ in C#
LINQ in C#
 
Advanced SharePoint Web Part Development
Advanced SharePoint Web Part DevelopmentAdvanced SharePoint Web Part Development
Advanced SharePoint Web Part Development
 
Request-Response Cycle of Ruby on Rails App
Request-Response Cycle of Ruby on Rails AppRequest-Response Cycle of Ruby on Rails App
Request-Response Cycle of Ruby on Rails App
 
Learn Ajax here
Learn Ajax hereLearn Ajax here
Learn Ajax here
 
Creating Modular Test-Driven SPAs with Spring and AngularJS
Creating Modular Test-Driven SPAs with Spring and AngularJSCreating Modular Test-Driven SPAs with Spring and AngularJS
Creating Modular Test-Driven SPAs with Spring and AngularJS
 
[2015/2016] Local data storage for web-based mobile apps
[2015/2016] Local data storage for web-based mobile apps[2015/2016] Local data storage for web-based mobile apps
[2015/2016] Local data storage for web-based mobile apps
 
Introduction to the SharePoint 2013 REST API
Introduction to the SharePoint 2013 REST APIIntroduction to the SharePoint 2013 REST API
Introduction to the SharePoint 2013 REST API
 
Introducing LINQ
Introducing LINQIntroducing LINQ
Introducing LINQ
 
Data Access Options in SharePoint 2010
Data Access Options in SharePoint 2010Data Access Options in SharePoint 2010
Data Access Options in SharePoint 2010
 
Learn AJAX at ASIT
Learn AJAX at ASITLearn AJAX at ASIT
Learn AJAX at ASIT
 
SharePoint 2010 Application Development Overview
SharePoint 2010 Application Development OverviewSharePoint 2010 Application Development Overview
SharePoint 2010 Application Development Overview
 
Session 35 - Design Patterns
Session 35 - Design PatternsSession 35 - Design Patterns
Session 35 - Design Patterns
 
ApacheCon North America 2018: Creating Spark Data Sources
ApacheCon North America 2018: Creating Spark Data SourcesApacheCon North America 2018: Creating Spark Data Sources
ApacheCon North America 2018: Creating Spark Data Sources
 
Slick – the modern way to access your Data
Slick – the modern way to access your DataSlick – the modern way to access your Data
Slick – the modern way to access your Data
 
06 integrate elasticsearch
06 integrate elasticsearch06 integrate elasticsearch
06 integrate elasticsearch
 
Angular
AngularAngular
Angular
 
Asp.net
Asp.netAsp.net
Asp.net
 

Ähnlich wie AngularJS 1.x - your first application (problems and solutions)

Tech io spa_angularjs_20130814_v0.9.5
Tech io spa_angularjs_20130814_v0.9.5Tech io spa_angularjs_20130814_v0.9.5
Tech io spa_angularjs_20130814_v0.9.5Ganesh Kondal
 
Play Framework and Activator
Play Framework and ActivatorPlay Framework and Activator
Play Framework and ActivatorKevin Webber
 
4 Anguadasdfasdasdfasdfsdfasdfaslar (1).pptx
4 Anguadasdfasdasdfasdfsdfasdfaslar (1).pptx4 Anguadasdfasdasdfasdfsdfasdfaslar (1).pptx
4 Anguadasdfasdasdfasdfsdfasdfaslar (1).pptxtilejak773
 
Introduction to angular | Concepts and Environment setup
Introduction to angular | Concepts and Environment setupIntroduction to angular | Concepts and Environment setup
Introduction to angular | Concepts and Environment setupAnsley Rodrigues
 
Дмитрий Тежельников «Разработка вэб-решений с использованием Asp.NET.Core и ...
Дмитрий Тежельников  «Разработка вэб-решений с использованием Asp.NET.Core и ...Дмитрий Тежельников  «Разработка вэб-решений с использованием Asp.NET.Core и ...
Дмитрий Тежельников «Разработка вэб-решений с использованием Asp.NET.Core и ...MskDotNet Community
 
SQL to NoSQL: Top 6 Questions
SQL to NoSQL: Top 6 QuestionsSQL to NoSQL: Top 6 Questions
SQL to NoSQL: Top 6 QuestionsMike Broberg
 
Web Development with Delphi and React - ITDevCon 2016
Web Development with Delphi and React - ITDevCon 2016Web Development with Delphi and React - ITDevCon 2016
Web Development with Delphi and React - ITDevCon 2016Marco Breveglieri
 
How to JavaOne 2016 - Generate Customized Java 8 Code from Your Database [TUT...
How to JavaOne 2016 - Generate Customized Java 8 Code from Your Database [TUT...How to JavaOne 2016 - Generate Customized Java 8 Code from Your Database [TUT...
How to JavaOne 2016 - Generate Customized Java 8 Code from Your Database [TUT...Malin Weiss
 
JavaOne2016 - How to Generate Customized Java 8 Code from Your Database [TUT4...
JavaOne2016 - How to Generate Customized Java 8 Code from Your Database [TUT4...JavaOne2016 - How to Generate Customized Java 8 Code from Your Database [TUT4...
JavaOne2016 - How to Generate Customized Java 8 Code from Your Database [TUT4...Speedment, Inc.
 
Lightning web components
Lightning web components Lightning web components
Lightning web components Cloud Analogy
 
Introduction to j2 ee frameworks
Introduction to j2 ee frameworksIntroduction to j2 ee frameworks
Introduction to j2 ee frameworksMukesh Kumar
 
Using MVC with Kentico 8
Using MVC with Kentico 8Using MVC with Kentico 8
Using MVC with Kentico 8Thomas Robbins
 
Getting Started with React, When You’re an Angular Developer
Getting Started with React, When You’re an Angular DeveloperGetting Started with React, When You’re an Angular Developer
Getting Started with React, When You’re an Angular DeveloperFabrit Global
 
Code for Startup MVP (Ruby on Rails) Session 1
Code for Startup MVP (Ruby on Rails) Session 1Code for Startup MVP (Ruby on Rails) Session 1
Code for Startup MVP (Ruby on Rails) Session 1Henry S
 
Spring MVC framework
Spring MVC frameworkSpring MVC framework
Spring MVC frameworkMohit Gupta
 
Service quality monitoring system architecture
Service quality monitoring system architectureService quality monitoring system architecture
Service quality monitoring system architectureMatsuo Sawahashi
 

Ähnlich wie AngularJS 1.x - your first application (problems and solutions) (20)

Tech io spa_angularjs_20130814_v0.9.5
Tech io spa_angularjs_20130814_v0.9.5Tech io spa_angularjs_20130814_v0.9.5
Tech io spa_angularjs_20130814_v0.9.5
 
Play Framework and Activator
Play Framework and ActivatorPlay Framework and Activator
Play Framework and Activator
 
4 Anguadasdfasdasdfasdfsdfasdfaslar (1).pptx
4 Anguadasdfasdasdfasdfsdfasdfaslar (1).pptx4 Anguadasdfasdasdfasdfsdfasdfaslar (1).pptx
4 Anguadasdfasdasdfasdfsdfasdfaslar (1).pptx
 
Introduction to angular | Concepts and Environment setup
Introduction to angular | Concepts and Environment setupIntroduction to angular | Concepts and Environment setup
Introduction to angular | Concepts and Environment setup
 
Дмитрий Тежельников «Разработка вэб-решений с использованием Asp.NET.Core и ...
Дмитрий Тежельников  «Разработка вэб-решений с использованием Asp.NET.Core и ...Дмитрий Тежельников  «Разработка вэб-решений с использованием Asp.NET.Core и ...
Дмитрий Тежельников «Разработка вэб-решений с использованием Asp.NET.Core и ...
 
SQL to NoSQL: Top 6 Questions
SQL to NoSQL: Top 6 QuestionsSQL to NoSQL: Top 6 Questions
SQL to NoSQL: Top 6 Questions
 
Web Development with Delphi and React - ITDevCon 2016
Web Development with Delphi and React - ITDevCon 2016Web Development with Delphi and React - ITDevCon 2016
Web Development with Delphi and React - ITDevCon 2016
 
How to JavaOne 2016 - Generate Customized Java 8 Code from Your Database [TUT...
How to JavaOne 2016 - Generate Customized Java 8 Code from Your Database [TUT...How to JavaOne 2016 - Generate Customized Java 8 Code from Your Database [TUT...
How to JavaOne 2016 - Generate Customized Java 8 Code from Your Database [TUT...
 
JavaOne2016 - How to Generate Customized Java 8 Code from Your Database [TUT4...
JavaOne2016 - How to Generate Customized Java 8 Code from Your Database [TUT4...JavaOne2016 - How to Generate Customized Java 8 Code from Your Database [TUT4...
JavaOne2016 - How to Generate Customized Java 8 Code from Your Database [TUT4...
 
Lightning web components
Lightning web components Lightning web components
Lightning web components
 
Introduction to j2 ee frameworks
Introduction to j2 ee frameworksIntroduction to j2 ee frameworks
Introduction to j2 ee frameworks
 
Using MVC with Kentico 8
Using MVC with Kentico 8Using MVC with Kentico 8
Using MVC with Kentico 8
 
70487.pdf
70487.pdf70487.pdf
70487.pdf
 
Asp 1a-aspnetmvc
Asp 1a-aspnetmvcAsp 1a-aspnetmvc
Asp 1a-aspnetmvc
 
Aspnetmvc 1
Aspnetmvc 1Aspnetmvc 1
Aspnetmvc 1
 
Getting Started with React, When You’re an Angular Developer
Getting Started with React, When You’re an Angular DeveloperGetting Started with React, When You’re an Angular Developer
Getting Started with React, When You’re an Angular Developer
 
Code for Startup MVP (Ruby on Rails) Session 1
Code for Startup MVP (Ruby on Rails) Session 1Code for Startup MVP (Ruby on Rails) Session 1
Code for Startup MVP (Ruby on Rails) Session 1
 
Spring MVC framework
Spring MVC frameworkSpring MVC framework
Spring MVC framework
 
Remix
RemixRemix
Remix
 
Service quality monitoring system architecture
Service quality monitoring system architectureService quality monitoring system architecture
Service quality monitoring system architecture
 

Kürzlich hochgeladen

%in tembisa+277-882-255-28 abortion pills for sale in tembisa
%in tembisa+277-882-255-28 abortion pills for sale in tembisa%in tembisa+277-882-255-28 abortion pills for sale in tembisa
%in tembisa+277-882-255-28 abortion pills for sale in tembisamasabamasaba
 
AI Mastery 201: Elevating Your Workflow with Advanced LLM Techniques
AI Mastery 201: Elevating Your Workflow with Advanced LLM TechniquesAI Mastery 201: Elevating Your Workflow with Advanced LLM Techniques
AI Mastery 201: Elevating Your Workflow with Advanced LLM TechniquesVictorSzoltysek
 
The Ultimate Test Automation Guide_ Best Practices and Tips.pdf
The Ultimate Test Automation Guide_ Best Practices and Tips.pdfThe Ultimate Test Automation Guide_ Best Practices and Tips.pdf
The Ultimate Test Automation Guide_ Best Practices and Tips.pdfkalichargn70th171
 
Direct Style Effect Systems - The Print[A] Example - A Comprehension Aid
Direct Style Effect Systems -The Print[A] Example- A Comprehension AidDirect Style Effect Systems -The Print[A] Example- A Comprehension Aid
Direct Style Effect Systems - The Print[A] Example - A Comprehension AidPhilip Schwarz
 
The Top App Development Trends Shaping the Industry in 2024-25 .pdf
The Top App Development Trends Shaping the Industry in 2024-25 .pdfThe Top App Development Trends Shaping the Industry in 2024-25 .pdf
The Top App Development Trends Shaping the Industry in 2024-25 .pdfayushiqss
 
%in Harare+277-882-255-28 abortion pills for sale in Harare
%in Harare+277-882-255-28 abortion pills for sale in Harare%in Harare+277-882-255-28 abortion pills for sale in Harare
%in Harare+277-882-255-28 abortion pills for sale in Hararemasabamasaba
 
VTU technical seminar 8Th Sem on Scikit-learn
VTU technical seminar 8Th Sem on Scikit-learnVTU technical seminar 8Th Sem on Scikit-learn
VTU technical seminar 8Th Sem on Scikit-learnAmarnathKambale
 
%in Stilfontein+277-882-255-28 abortion pills for sale in Stilfontein
%in Stilfontein+277-882-255-28 abortion pills for sale in Stilfontein%in Stilfontein+277-882-255-28 abortion pills for sale in Stilfontein
%in Stilfontein+277-882-255-28 abortion pills for sale in Stilfonteinmasabamasaba
 
introduction-to-automotive Andoid os-csimmonds-ndctechtown-2021.pdf
introduction-to-automotive Andoid os-csimmonds-ndctechtown-2021.pdfintroduction-to-automotive Andoid os-csimmonds-ndctechtown-2021.pdf
introduction-to-automotive Andoid os-csimmonds-ndctechtown-2021.pdfVishalKumarJha10
 
Chinsurah Escorts ☎️8617697112 Starting From 5K to 15K High Profile Escorts ...
Chinsurah Escorts ☎️8617697112  Starting From 5K to 15K High Profile Escorts ...Chinsurah Escorts ☎️8617697112  Starting From 5K to 15K High Profile Escorts ...
Chinsurah Escorts ☎️8617697112 Starting From 5K to 15K High Profile Escorts ...Nitya salvi
 
%in Midrand+277-882-255-28 abortion pills for sale in midrand
%in Midrand+277-882-255-28 abortion pills for sale in midrand%in Midrand+277-882-255-28 abortion pills for sale in midrand
%in Midrand+277-882-255-28 abortion pills for sale in midrandmasabamasaba
 
Right Money Management App For Your Financial Goals
Right Money Management App For Your Financial GoalsRight Money Management App For Your Financial Goals
Right Money Management App For Your Financial GoalsJhone kinadey
 
Unlocking the Future of AI Agents with Large Language Models
Unlocking the Future of AI Agents with Large Language ModelsUnlocking the Future of AI Agents with Large Language Models
Unlocking the Future of AI Agents with Large Language Modelsaagamshah0812
 
%+27788225528 love spells in Boston Psychic Readings, Attraction spells,Bring...
%+27788225528 love spells in Boston Psychic Readings, Attraction spells,Bring...%+27788225528 love spells in Boston Psychic Readings, Attraction spells,Bring...
%+27788225528 love spells in Boston Psychic Readings, Attraction spells,Bring...masabamasaba
 
call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️
call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️
call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️Delhi Call girls
 
%in Lydenburg+277-882-255-28 abortion pills for sale in Lydenburg
%in Lydenburg+277-882-255-28 abortion pills for sale in Lydenburg%in Lydenburg+277-882-255-28 abortion pills for sale in Lydenburg
%in Lydenburg+277-882-255-28 abortion pills for sale in Lydenburgmasabamasaba
 
Architecture decision records - How not to get lost in the past
Architecture decision records - How not to get lost in the pastArchitecture decision records - How not to get lost in the past
Architecture decision records - How not to get lost in the pastPapp Krisztián
 
8257 interfacing 2 in microprocessor for btech students
8257 interfacing 2 in microprocessor for btech students8257 interfacing 2 in microprocessor for btech students
8257 interfacing 2 in microprocessor for btech studentsHimanshiGarg82
 
%in ivory park+277-882-255-28 abortion pills for sale in ivory park
%in ivory park+277-882-255-28 abortion pills for sale in ivory park %in ivory park+277-882-255-28 abortion pills for sale in ivory park
%in ivory park+277-882-255-28 abortion pills for sale in ivory park masabamasaba
 

Kürzlich hochgeladen (20)

%in tembisa+277-882-255-28 abortion pills for sale in tembisa
%in tembisa+277-882-255-28 abortion pills for sale in tembisa%in tembisa+277-882-255-28 abortion pills for sale in tembisa
%in tembisa+277-882-255-28 abortion pills for sale in tembisa
 
AI Mastery 201: Elevating Your Workflow with Advanced LLM Techniques
AI Mastery 201: Elevating Your Workflow with Advanced LLM TechniquesAI Mastery 201: Elevating Your Workflow with Advanced LLM Techniques
AI Mastery 201: Elevating Your Workflow with Advanced LLM Techniques
 
The Ultimate Test Automation Guide_ Best Practices and Tips.pdf
The Ultimate Test Automation Guide_ Best Practices and Tips.pdfThe Ultimate Test Automation Guide_ Best Practices and Tips.pdf
The Ultimate Test Automation Guide_ Best Practices and Tips.pdf
 
Direct Style Effect Systems - The Print[A] Example - A Comprehension Aid
Direct Style Effect Systems -The Print[A] Example- A Comprehension AidDirect Style Effect Systems -The Print[A] Example- A Comprehension Aid
Direct Style Effect Systems - The Print[A] Example - A Comprehension Aid
 
The Top App Development Trends Shaping the Industry in 2024-25 .pdf
The Top App Development Trends Shaping the Industry in 2024-25 .pdfThe Top App Development Trends Shaping the Industry in 2024-25 .pdf
The Top App Development Trends Shaping the Industry in 2024-25 .pdf
 
%in Harare+277-882-255-28 abortion pills for sale in Harare
%in Harare+277-882-255-28 abortion pills for sale in Harare%in Harare+277-882-255-28 abortion pills for sale in Harare
%in Harare+277-882-255-28 abortion pills for sale in Harare
 
VTU technical seminar 8Th Sem on Scikit-learn
VTU technical seminar 8Th Sem on Scikit-learnVTU technical seminar 8Th Sem on Scikit-learn
VTU technical seminar 8Th Sem on Scikit-learn
 
%in Stilfontein+277-882-255-28 abortion pills for sale in Stilfontein
%in Stilfontein+277-882-255-28 abortion pills for sale in Stilfontein%in Stilfontein+277-882-255-28 abortion pills for sale in Stilfontein
%in Stilfontein+277-882-255-28 abortion pills for sale in Stilfontein
 
introduction-to-automotive Andoid os-csimmonds-ndctechtown-2021.pdf
introduction-to-automotive Andoid os-csimmonds-ndctechtown-2021.pdfintroduction-to-automotive Andoid os-csimmonds-ndctechtown-2021.pdf
introduction-to-automotive Andoid os-csimmonds-ndctechtown-2021.pdf
 
Chinsurah Escorts ☎️8617697112 Starting From 5K to 15K High Profile Escorts ...
Chinsurah Escorts ☎️8617697112  Starting From 5K to 15K High Profile Escorts ...Chinsurah Escorts ☎️8617697112  Starting From 5K to 15K High Profile Escorts ...
Chinsurah Escorts ☎️8617697112 Starting From 5K to 15K High Profile Escorts ...
 
%in Midrand+277-882-255-28 abortion pills for sale in midrand
%in Midrand+277-882-255-28 abortion pills for sale in midrand%in Midrand+277-882-255-28 abortion pills for sale in midrand
%in Midrand+277-882-255-28 abortion pills for sale in midrand
 
Right Money Management App For Your Financial Goals
Right Money Management App For Your Financial GoalsRight Money Management App For Your Financial Goals
Right Money Management App For Your Financial Goals
 
Unlocking the Future of AI Agents with Large Language Models
Unlocking the Future of AI Agents with Large Language ModelsUnlocking the Future of AI Agents with Large Language Models
Unlocking the Future of AI Agents with Large Language Models
 
Microsoft AI Transformation Partner Playbook.pdf
Microsoft AI Transformation Partner Playbook.pdfMicrosoft AI Transformation Partner Playbook.pdf
Microsoft AI Transformation Partner Playbook.pdf
 
%+27788225528 love spells in Boston Psychic Readings, Attraction spells,Bring...
%+27788225528 love spells in Boston Psychic Readings, Attraction spells,Bring...%+27788225528 love spells in Boston Psychic Readings, Attraction spells,Bring...
%+27788225528 love spells in Boston Psychic Readings, Attraction spells,Bring...
 
call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️
call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️
call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️
 
%in Lydenburg+277-882-255-28 abortion pills for sale in Lydenburg
%in Lydenburg+277-882-255-28 abortion pills for sale in Lydenburg%in Lydenburg+277-882-255-28 abortion pills for sale in Lydenburg
%in Lydenburg+277-882-255-28 abortion pills for sale in Lydenburg
 
Architecture decision records - How not to get lost in the past
Architecture decision records - How not to get lost in the pastArchitecture decision records - How not to get lost in the past
Architecture decision records - How not to get lost in the past
 
8257 interfacing 2 in microprocessor for btech students
8257 interfacing 2 in microprocessor for btech students8257 interfacing 2 in microprocessor for btech students
8257 interfacing 2 in microprocessor for btech students
 
%in ivory park+277-882-255-28 abortion pills for sale in ivory park
%in ivory park+277-882-255-28 abortion pills for sale in ivory park %in ivory park+277-882-255-28 abortion pills for sale in ivory park
%in ivory park+277-882-255-28 abortion pills for sale in ivory park
 

AngularJS 1.x - your first application (problems and solutions)

  • 1.
  • 2. Igor Talevski Developer @ http://it-labs.com/ 2 @TalevskiIgor
  • 4. General Sponsors Platinum Sponsors Silver Sponsors Gold Sponsors Bronze Sponsors 4
  • 7. SPA concepts • SPA works and feels more like an application then a web page. • SPA separates UI and data, SPA communicates with server only with JSON REST API (Send/Receive JSON using AJAX) • Reducing bandwidth usage is also a plus • SPA can use caching and local storage effectively. • You can easily fake JSON data communication to test SPA, and you can also easily fake JSON requests to server to write unit tests. • Some SPAs don’t require SEO, but for those that do, the solutions aren’t straightforward. • Analytics is harder to implement 7 Single-Page Applications (SPAs) are Web apps that load a single HTML page and dynamically update that page as the user interacts with the app.
  • 10. Automatic Initialization • load the module associated with the directive. • create the application injector • compile the DOM treating the ngApp directive as the root of the compilation. (This allows you to tell it to treat only a portion of the DOM as an Angular application.) 10 Angular initializes automatically upon DOMContentLoaded event or when the angular.js script is evaluated if at that time document.readyState is set to 'complete‘.
  • 11. Manual Initialization • After the page and all of the code is loaded, find the root element of your AngularJS application, which is typically the root of the document. • Call angular.bootstrap to compile the element into an executable, bi-directionally bound application. 11 If you need to have more control over the initialization process, you can use a manual bootstrapping method instead. Examples of when you'd need to do this include using script loaders or the need to perform an operation before Angular compiles a page.
  • 16. 16
  • 18. Application Structure LIFT Principle • Make locating your code intuitive, simple and fast. • When you look at a file you should instantly know what it contains and represents. • Keep a flat folder structure as long as possible. When you get to 8+ files, begin considering separation. • Be DRY, but don't go nuts and sacrifice readability. 18 Structure your app such that you can Locate your code quickly Identify the code at a glance keep the Flattest structure you can and Try to stay DRY.
  • 19. 19 Module You can think of a module as a container for the different parts of your app – controllers, services, filters, directives, etc…
  • 20. Data Binding 20 Automatic synchronization of data between the model and view
  • 21. Controllers Use controllers to: • Set up the initial state of the $scope object. • Add behavior to the $scope object. Do not use controllers to: • Manipulate DOM — Controllers should contain only business logic. • Format input — Use angular form controls instead. • Filter output — Use angular filters instead. • Share code or state across controllers — Use angular services instead. • Manage the life-cycle of other components (to create service instances). 21 In Angular, a Controller is defined by a JavaScript constructor function that is used to augment the Angular Scope.
  • 22. Nesting controllers • The root scope • The MainController scope • The ChildController scope • The GrandChildController scope 22
  • 24. Dependency Injection 24 Dependency Injection (DI) is a software design pattern that deals with how components get hold of their dependencies.
  • 25. Dependency Annotation 25 Angular invokes certain functions (like service factories and controllers) via the injector. You need to annotate these functions so that the injector knows what services to inject into the function. Inline Array Annotation Property Annotation Implicit Annotation
  • 26. Useful Tools For Developers 26 Yeoman generator for AngularJS - lets you quickly set up a project with sensible defaults and best practices.
  • 27. Useful Tools For Developers 27
  • 28. Useful Tools For Developers 28 • (local server) The actual grunt server • (jshint) Make sure there are no obvious mistakes • (jscs) Make sure code styles are up to par • (clean) Empties folders to start fresh • (postcss) Add vendor prefixed styles • (wiredep) Automatically inject Bower components into the app • (compass) Compiles Sass to CSS and generates necessary files if requested • (filerev) Renames files for browser caching purposes • (usemin) Performs rewrites based on filerev and the useminPrepare configuration • (ngAnnotate) *tries to make the code safe for minification automatically • (ngTemplate) register your AngularJS templates in the $templateCache • (livereload) Watches files for changes and runs tasks based on the changed files • uglify, cssmin, imagemin, svgmin, htmlmin, etc ...
  • 29. Useful Packages 29 • ng-constant If you develop a website that uses multiple environments such as development, staging and production you probably have a configuration file of sorts to handle things like database settings, mail server credentials, and so on for your backend system. But how do you handle such variables in the front-end? Specifically, in an AngularJS App?
  • 30. Directives • 'A' - only matches attribute name • 'E' - only matches element name • 'C' - only matches class name • 'M' - only matches comment 30 At a high level, directives are markers on a DOM element (such as an attribute, element name, comment or CSS class) that tell AngularJS's HTML compiler ($compile) to attach a specified behavior to that DOM element (e.g. via event listeners), or even to transform the DOM element and its children.
  • 31. Getting data from the server 31
  • 32. Getting data from the server 32
  • 33. Getting data from the server 33 • data – {string | Object} – The response body transformed with the transform functions. • status – {number} – HTTP status code of the response. • headers – {function([headerName])} – Header getter function. • config – {Object} – The configuration object that was used to generate the request. • statusText – {string} – HTTP status text of the response.
  • 36. 36 Usage of Service Repository
  • 37. 37 Same-origin policy The same-origin policy restricts how a document or script loaded from one origin can interact with a resource from another origin. It is a critical security mechanism for isolating potentially malicious documents.
  • 41. AngularUI Router 41 Routing frameworks for SPAs update the browser's URL as the user nagivates through the app.
  • 42. JWT 42 JSON Web Tokens are an open, industry standard RFC 7519 method for representing claims securely between two parties.
  • 43. Interceptors 43 For purposes of global error handling, authentication, or any kind of synchronous or asynchronous pre-processing of request or postprocessing of responses, it is desirable to be able to intercept requests before they are handed to the server and responses before they are handed over to the application code that initiated these requests.
  • 44. WebSockets 44 is an advanced technology that makes it possible to open an interactive communication session between the user's browser and a server.
  • 48. Complete the evaluation and earn the chance to win prizes in the closing raffle http://eval.codecamp.mk 48 Questions