SlideShare a Scribd company logo
UI-Router 
The hero we need… 
Loc Nguyen
• 6:30 - 7:00 – Food and networking 
• 7:00 - 7:05 – Announcements, LoanNow intro 
• 7:05 - 7:30 – Restangular Lightning Talk 
• 7:30 - 8:15 – UI-Router 
• 8:15 - 8:25 – Wrap up and raffle
<ng-selfie /> 
• Multi-platform SW engineering geek => 
Java, Ruby, JavaScript, C#, Node 
• ~1.5 years of AngularJS experience => 
mostly freelancing 
• Preferred Ember at first! 
• Speaking at OC Java UG in October
ngRoute :-( 
• Transitions by URL 
• Work-arounds to handle nested views 
• Directives 
• ngInclude 
• ngSwitch
UI-Router (>^_^)> 
• Transitions by state rather then by URL 
• Define and design states your application can be in 
• Nested states!
States 
• Not all states need a URL, e.g. a modal, section 
expansion 
• Can configure in any order 
• Can configure across modules
Nested States 
• Can configure child states before parents 
• A child state and its ancestors are active 
• Inherit parent dependencies using the resolve map
UI-Router Services 
• $stateProvider – define state transitions 
• $state – transition to another state, check what the 
current state is 
• $stateParams – get route and query parameter values for 
the current state
Simple State Configuration 
angular.module('helloApp').config(function($stateProvider) { 
$stateProvider.state('login', { 
url: '/login', 
templateUrl: 'views/login.html' 
}) 
});
Diff with ngRoute 
angular.module('helloApp').config(function($stateProvider) { 
$stateProvider.state('login', { 
url: '/login', 
templateUrl: 'views/login.html' 
}) 
}); 
angular.module('helloApp').config(function($routeProvider) { 
$routeProvider.when('/login', { 
templateUrl: 'views/login.html' 
}) 
});
Nested State Configuration 
angular.module('helloApp').config(function ($stateProvider) { 
$stateProvider.state('app', { 
template: '<html><body><header>you fancy</header>' + 
'<ui-view></ui-view></body></html>' 
}).state('app.login', { 
url: '/login', 
templateUrl: 'views/login.html' 
}); 
});
Transitioning States 
$state.go('login'); 
angular.module('sampleApp').config(function ($stateProvider) { 
$stateProvider.state('acount', { 
url: '/account/:id?showDetails', 
templateUrl: 'views/account.html' 
}); 
}); 
$state.go('account', { id: 47, showDetails: true });
In & Out Callbacks 
angular.module('sampleApp').config(function ($stateProvider) { 
$stateProvider.state('app.acount', { 
url: '/account/:id', 
templateUrl: 'views/account.html', 
onEnter: function () { 
console.log('Google Analytics, open modal etc'); 
}, 
onExit: function () { 
console.log('clean up, animate etc'); 
} 
}); 
});
UI-Router Directives 
• uiSref – declarative link to a state 
• uiSrefActive – adds CSS classes when a state is active 
• uiView – where to place the state template
UI-Router Directives 
• uiSref is UI-Router’s ngHref 
angular.module('sampleApp').config(function ($stateProvider) { 
$stateProvider.state('acount', { 
url: '/account/:id?showDetails', 
templateUrl: 'views/account.html' 
}); 
}); 
<a ui-sref="login">Login</a> 
<a ui-sref="account({ id: 47, showDetails: true })">Account</a>
UI-Router Directives 
• uiView is UI-Router’s version of ngView 
• Tells UI-Router where to inject our views 
• Supports named views 
<html> 
<body> 
<header></header> 
<ui-view></ui-view> 
</body> 
</html>
Named Views 
• More than one uiView in a template 
• Flexible and dynamic layouts 
<html> 
<body> 
<ui-view="header"></ui-view> 
<ui-view="sideNav"></ui-view> 
<ui-view="mainContent"></ui-view> 
</body> 
</html>
Named Views 
angular.module('sampleApp').config(function ($stateProvider) { 
$stateProvider.state('login', { 
url: '/login', 
views: { 
'header': { templateUrl: 'views/unauth-header.html' }, 
'sideNav': { templateUrl: 'views/unauth-sidenav.html' }, 
'content': { templateUrl: 'views/login.html' } 
} 
}); 
});
Resolve & Controllers 
angular.module('sampleApp').config(function ($stateProvider) { 
$stateProvider.state('app.acount', { 
url: '/account/:id', 
templateUrl: 'views/account.html', 
resolve: { 
account: function ($http, $stateParams) { 
return $http.get('/api/account/' + $stateParams.id); 
} 
}, 
controller: function (account) { … } 
controller: 'AccountController' 
controller: ‘AccountController as account' 
}); 
});
Nested Resolve & Controllers 
angular.module('sampleApp').config(function ($stateProvider) { 
$stateProvider.state('account', { 
url: '/account/:id', 
templateUrl: 'views/account.html', 
resolve: { 
account: function ($http, $stateParams) { … } 
} 
}) 
.state('account.details', { 
controller: function (account, DetailService) { … } 
}); 
});
And more… 
• Regex parameters: 
url: “/contacts/{contactId:[0-9]{1,8}}" 
• $urlRouterProvider – watches $location and matches 
against URL configurations
Resources 
• Egghead.io UI-Router Cheat sheet: 
http://goo.gl/ZcL0dv 
• UI-Router at CincyNG meetup: 
https://www.youtube.com/watch?v=lBqiZSemrqg 
• UI-Router extras: 
https://github.com/christopherthielen/ui-router-extras
Didn't win? Get a HUGE discount on the course by visiting: 
http://tinyurl.com/AngularJSJumpstart
UI-Router

More Related Content

What's hot

Dive into AngularJS Routing
Dive into AngularJS RoutingDive into AngularJS Routing
Dive into AngularJS Routing
Egor Miasnikov
 
Building an End-to-End AngularJS Application
Building an End-to-End AngularJS ApplicationBuilding an End-to-End AngularJS Application
Building an End-to-End AngularJS Application
Dan Wahlin
 
Angular 2.0 Routing and Navigation
Angular 2.0 Routing and NavigationAngular 2.0 Routing and Navigation
Angular 2.0 Routing and Navigation
Eyal Vardi
 
Angular JS blog tutorial
Angular JS blog tutorialAngular JS blog tutorial
Angular JS blog tutorial
Claude Tech
 
Building a dashboard using AngularJS
Building a dashboard using AngularJSBuilding a dashboard using AngularJS
Building a dashboard using AngularJS
RajthilakMCA
 
multiple views and routing
multiple views and routingmultiple views and routing
multiple views and routingBrajesh Yadav
 
Up and Running with ReactJS
Up and Running with ReactJSUp and Running with ReactJS
Up and Running with ReactJS
Loc Nguyen
 
Understanding angular js $rootscope and $scope
Understanding angular js $rootscope and $scopeUnderstanding angular js $rootscope and $scope
Understanding angular js $rootscope and $scope
Brajesh Yadav
 
Controller in AngularJS
Controller in AngularJSController in AngularJS
Controller in AngularJS
Brajesh Yadav
 
Ionic tabs template explained
Ionic tabs template explainedIonic tabs template explained
Ionic tabs template explained
Ramesh BN
 
Get AngularJS Started!
Get AngularJS Started!Get AngularJS Started!
Get AngularJS Started!
Dzmitry Ivashutsin
 
Beyond DOMReady: Ultra High-Performance Javascript
Beyond DOMReady: Ultra High-Performance JavascriptBeyond DOMReady: Ultra High-Performance Javascript
Beyond DOMReady: Ultra High-Performance Javascript
aglemann
 
CFUGbe talk about Angular JS
CFUGbe talk about Angular JSCFUGbe talk about Angular JS
CFUGbe talk about Angular JS
Alwyn Wymeersch
 
Directives
DirectivesDirectives
Directives
Brajesh Yadav
 
Why angular js Framework
Why angular js Framework Why angular js Framework
Why angular js Framework
Sakthi Bro
 
Rails3 asset-pipeline
Rails3 asset-pipelineRails3 asset-pipeline
Rails3 asset-pipeline
Damian Galarza
 
Short intro to JQuery and Modernizr
Short intro to JQuery and ModernizrShort intro to JQuery and Modernizr
Short intro to JQuery and ModernizrJussi Pohjolainen
 

What's hot (20)

Dive into AngularJS Routing
Dive into AngularJS RoutingDive into AngularJS Routing
Dive into AngularJS Routing
 
Building an End-to-End AngularJS Application
Building an End-to-End AngularJS ApplicationBuilding an End-to-End AngularJS Application
Building an End-to-End AngularJS Application
 
Angular 2.0 Routing and Navigation
Angular 2.0 Routing and NavigationAngular 2.0 Routing and Navigation
Angular 2.0 Routing and Navigation
 
Angular JS blog tutorial
Angular JS blog tutorialAngular JS blog tutorial
Angular JS blog tutorial
 
Building a dashboard using AngularJS
Building a dashboard using AngularJSBuilding a dashboard using AngularJS
Building a dashboard using AngularJS
 
multiple views and routing
multiple views and routingmultiple views and routing
multiple views and routing
 
Up and Running with ReactJS
Up and Running with ReactJSUp and Running with ReactJS
Up and Running with ReactJS
 
Understanding angular js $rootscope and $scope
Understanding angular js $rootscope and $scopeUnderstanding angular js $rootscope and $scope
Understanding angular js $rootscope and $scope
 
Built in filters
Built in filtersBuilt in filters
Built in filters
 
J queryui
J queryuiJ queryui
J queryui
 
Controller in AngularJS
Controller in AngularJSController in AngularJS
Controller in AngularJS
 
Ionic tabs template explained
Ionic tabs template explainedIonic tabs template explained
Ionic tabs template explained
 
Get AngularJS Started!
Get AngularJS Started!Get AngularJS Started!
Get AngularJS Started!
 
Beyond DOMReady: Ultra High-Performance Javascript
Beyond DOMReady: Ultra High-Performance JavascriptBeyond DOMReady: Ultra High-Performance Javascript
Beyond DOMReady: Ultra High-Performance Javascript
 
CFUGbe talk about Angular JS
CFUGbe talk about Angular JSCFUGbe talk about Angular JS
CFUGbe talk about Angular JS
 
Directives
DirectivesDirectives
Directives
 
Why angular js Framework
Why angular js Framework Why angular js Framework
Why angular js Framework
 
Rails3 asset-pipeline
Rails3 asset-pipelineRails3 asset-pipeline
Rails3 asset-pipeline
 
JQuery
JQueryJQuery
JQuery
 
Short intro to JQuery and Modernizr
Short intro to JQuery and ModernizrShort intro to JQuery and Modernizr
Short intro to JQuery and Modernizr
 

Viewers also liked

Intro to UI-Router/TypeScript
Intro to UI-Router/TypeScriptIntro to UI-Router/TypeScript
Intro to UI-Router/TypeScript
Jamal Sinclair O'Garro
 
Angular Promises and Advanced Routing
Angular Promises and Advanced RoutingAngular Promises and Advanced Routing
Angular Promises and Advanced Routing
Alexe Bogdan
 
Introduction about-ajax-framework
Introduction about-ajax-frameworkIntroduction about-ajax-framework
Introduction about-ajax-framework
Sakthi Bro
 
Single Page Application presentation
Single Page Application presentationSingle Page Application presentation
Single Page Application presentation
John Staveley
 
Introduction To Single Page Application
Introduction To Single Page ApplicationIntroduction To Single Page Application
Introduction To Single Page ApplicationKMS Technology
 
Single Page Application (SPA) using AngularJS
Single Page Application (SPA) using AngularJSSingle Page Application (SPA) using AngularJS
Single Page Application (SPA) using AngularJS
M R Rony
 
AngularJS Basics with Example
AngularJS Basics with ExampleAngularJS Basics with Example
AngularJS Basics with Example
Sergey Bolshchikov
 
AngularJS Architecture
AngularJS ArchitectureAngularJS Architecture
AngularJS Architecture
Eyal Vardi
 

Viewers also liked (9)

Intro to UI-Router/TypeScript
Intro to UI-Router/TypeScriptIntro to UI-Router/TypeScript
Intro to UI-Router/TypeScript
 
Angular Promises and Advanced Routing
Angular Promises and Advanced RoutingAngular Promises and Advanced Routing
Angular Promises and Advanced Routing
 
Introduction about-ajax-framework
Introduction about-ajax-frameworkIntroduction about-ajax-framework
Introduction about-ajax-framework
 
Single Page Application presentation
Single Page Application presentationSingle Page Application presentation
Single Page Application presentation
 
Introduction To Single Page Application
Introduction To Single Page ApplicationIntroduction To Single Page Application
Introduction To Single Page Application
 
Single Page Application (SPA) using AngularJS
Single Page Application (SPA) using AngularJSSingle Page Application (SPA) using AngularJS
Single Page Application (SPA) using AngularJS
 
AngularJS Basics with Example
AngularJS Basics with ExampleAngularJS Basics with Example
AngularJS Basics with Example
 
AngularJS Architecture
AngularJS ArchitectureAngularJS Architecture
AngularJS Architecture
 
Introduction to Angularjs
Introduction to AngularjsIntroduction to Angularjs
Introduction to Angularjs
 

Similar to UI-Router

AngularJS in 60ish Minutes - Dan Wahlin | FalafelCON 2014
AngularJS in 60ish Minutes - Dan Wahlin | FalafelCON 2014AngularJS in 60ish Minutes - Dan Wahlin | FalafelCON 2014
AngularJS in 60ish Minutes - Dan Wahlin | FalafelCON 2014
FalafelSoftware
 
Coffee@DBG - Exploring Angular JS
Coffee@DBG - Exploring Angular JSCoffee@DBG - Exploring Angular JS
Coffee@DBG - Exploring Angular JS
Deepu S Nath
 
MEAN - Notes from the field (Full-Stack Development with Javascript)
MEAN - Notes from the field (Full-Stack Development with Javascript)MEAN - Notes from the field (Full-Stack Development with Javascript)
MEAN - Notes from the field (Full-Stack Development with Javascript)
Chris Clarke
 
AngularJS for Java Developers
AngularJS for Java DevelopersAngularJS for Java Developers
AngularJS for Java Developers
Loc Nguyen
 
Introduction of angular js
Introduction of angular jsIntroduction of angular js
Introduction of angular js
Tamer Solieman
 
Mini-Training: AngularJS
Mini-Training: AngularJSMini-Training: AngularJS
Mini-Training: AngularJS
Betclic Everest Group Tech Team
 
Angular.js опыт использования, проблемы и решения
Angular.js опыт использования, проблемы и решенияAngular.js опыт использования, проблемы и решения
Angular.js опыт использования, проблемы и решения
Olga Lavrentieva
 
Introduction to AngularJS For WordPress Developers
Introduction to AngularJS For WordPress DevelopersIntroduction to AngularJS For WordPress Developers
Introduction to AngularJS For WordPress Developers
Caldera Labs
 
243329387 angular-docs
243329387 angular-docs243329387 angular-docs
243329387 angular-docs
Abhi166803
 
Good karma: UX Patterns and Unit Testing in Angular with Karma
Good karma: UX Patterns and Unit Testing in Angular with KarmaGood karma: UX Patterns and Unit Testing in Angular with Karma
Good karma: UX Patterns and Unit Testing in Angular with Karma
ExoLeaders.com
 
AngularJS.part1
AngularJS.part1AngularJS.part1
AngularJS.part1
Andrey Kolodnitsky
 
Basics of AngularJS
Basics of AngularJSBasics of AngularJS
Basics of AngularJS
Filip Janevski
 
The Art of AngularJS in 2015 - Angular Summit 2015
The Art of AngularJS in 2015 - Angular Summit 2015The Art of AngularJS in 2015 - Angular Summit 2015
The Art of AngularJS in 2015 - Angular Summit 2015
Matt Raible
 
AngularJS 101 - Everything you need to know to get started
AngularJS 101 - Everything you need to know to get startedAngularJS 101 - Everything you need to know to get started
AngularJS 101 - Everything you need to know to get started
Stéphane Bégaudeau
 
AngularJS in 60ish Minutes
AngularJS in 60ish MinutesAngularJS in 60ish Minutes
AngularJS in 60ish Minutes
Dan Wahlin
 
Opencast Admin UI - Introduction to developing using AngularJS
Opencast Admin UI - Introduction to developing using AngularJSOpencast Admin UI - Introduction to developing using AngularJS
Opencast Admin UI - Introduction to developing using AngularJS
buttyx
 
Different way to share data between controllers in angular js
Different way to share data between controllers in angular jsDifferent way to share data between controllers in angular js
Different way to share data between controllers in angular js
codeandyou forums
 
Sharing Data between controllers in different ways.
Sharing Data between controllers in different ways.Sharing Data between controllers in different ways.
Sharing Data between controllers in different ways.
Amar Shukla
 

Similar to UI-Router (20)

AngularJS in 60ish Minutes - Dan Wahlin | FalafelCON 2014
AngularJS in 60ish Minutes - Dan Wahlin | FalafelCON 2014AngularJS in 60ish Minutes - Dan Wahlin | FalafelCON 2014
AngularJS in 60ish Minutes - Dan Wahlin | FalafelCON 2014
 
Coffee@DBG - Exploring Angular JS
Coffee@DBG - Exploring Angular JSCoffee@DBG - Exploring Angular JS
Coffee@DBG - Exploring Angular JS
 
MEAN - Notes from the field (Full-Stack Development with Javascript)
MEAN - Notes from the field (Full-Stack Development with Javascript)MEAN - Notes from the field (Full-Stack Development with Javascript)
MEAN - Notes from the field (Full-Stack Development with Javascript)
 
Angular - Beginner
Angular - BeginnerAngular - Beginner
Angular - Beginner
 
AngularJS for Java Developers
AngularJS for Java DevelopersAngularJS for Java Developers
AngularJS for Java Developers
 
Introduction of angular js
Introduction of angular jsIntroduction of angular js
Introduction of angular js
 
Mini-Training: AngularJS
Mini-Training: AngularJSMini-Training: AngularJS
Mini-Training: AngularJS
 
Angular.js опыт использования, проблемы и решения
Angular.js опыт использования, проблемы и решенияAngular.js опыт использования, проблемы и решения
Angular.js опыт использования, проблемы и решения
 
Introduction to AngularJS For WordPress Developers
Introduction to AngularJS For WordPress DevelopersIntroduction to AngularJS For WordPress Developers
Introduction to AngularJS For WordPress Developers
 
243329387 angular-docs
243329387 angular-docs243329387 angular-docs
243329387 angular-docs
 
Good karma: UX Patterns and Unit Testing in Angular with Karma
Good karma: UX Patterns and Unit Testing in Angular with KarmaGood karma: UX Patterns and Unit Testing in Angular with Karma
Good karma: UX Patterns and Unit Testing in Angular with Karma
 
AngularJS.part1
AngularJS.part1AngularJS.part1
AngularJS.part1
 
Basics of AngularJS
Basics of AngularJSBasics of AngularJS
Basics of AngularJS
 
The Art of AngularJS in 2015 - Angular Summit 2015
The Art of AngularJS in 2015 - Angular Summit 2015The Art of AngularJS in 2015 - Angular Summit 2015
The Art of AngularJS in 2015 - Angular Summit 2015
 
AngularJS 101 - Everything you need to know to get started
AngularJS 101 - Everything you need to know to get startedAngularJS 101 - Everything you need to know to get started
AngularJS 101 - Everything you need to know to get started
 
Angularjs
AngularjsAngularjs
Angularjs
 
AngularJS in 60ish Minutes
AngularJS in 60ish MinutesAngularJS in 60ish Minutes
AngularJS in 60ish Minutes
 
Opencast Admin UI - Introduction to developing using AngularJS
Opencast Admin UI - Introduction to developing using AngularJSOpencast Admin UI - Introduction to developing using AngularJS
Opencast Admin UI - Introduction to developing using AngularJS
 
Different way to share data between controllers in angular js
Different way to share data between controllers in angular jsDifferent way to share data between controllers in angular js
Different way to share data between controllers in angular js
 
Sharing Data between controllers in different ways.
Sharing Data between controllers in different ways.Sharing Data between controllers in different ways.
Sharing Data between controllers in different ways.
 

Recently uploaded

Technical Drawings introduction to drawing of prisms
Technical Drawings introduction to drawing of prismsTechnical Drawings introduction to drawing of prisms
Technical Drawings introduction to drawing of prisms
heavyhaig
 
Tutorial for 16S rRNA Gene Analysis with QIIME2.pdf
Tutorial for 16S rRNA Gene Analysis with QIIME2.pdfTutorial for 16S rRNA Gene Analysis with QIIME2.pdf
Tutorial for 16S rRNA Gene Analysis with QIIME2.pdf
aqil azizi
 
AKS UNIVERSITY Satna Final Year Project By OM Hardaha.pdf
AKS UNIVERSITY Satna Final Year Project By OM Hardaha.pdfAKS UNIVERSITY Satna Final Year Project By OM Hardaha.pdf
AKS UNIVERSITY Satna Final Year Project By OM Hardaha.pdf
SamSarthak3
 
14 Template Contractual Notice - EOT Application
14 Template Contractual Notice - EOT Application14 Template Contractual Notice - EOT Application
14 Template Contractual Notice - EOT Application
SyedAbiiAzazi1
 
MCQ Soil mechanics questions (Soil shear strength).pdf
MCQ Soil mechanics questions (Soil shear strength).pdfMCQ Soil mechanics questions (Soil shear strength).pdf
MCQ Soil mechanics questions (Soil shear strength).pdf
Osamah Alsalih
 
Industrial Training at Shahjalal Fertilizer Company Limited (SFCL)
Industrial Training at Shahjalal Fertilizer Company Limited (SFCL)Industrial Training at Shahjalal Fertilizer Company Limited (SFCL)
Industrial Training at Shahjalal Fertilizer Company Limited (SFCL)
MdTanvirMahtab2
 
Understanding Inductive Bias in Machine Learning
Understanding Inductive Bias in Machine LearningUnderstanding Inductive Bias in Machine Learning
Understanding Inductive Bias in Machine Learning
SUTEJAS
 
An Approach to Detecting Writing Styles Based on Clustering Techniques
An Approach to Detecting Writing Styles Based on Clustering TechniquesAn Approach to Detecting Writing Styles Based on Clustering Techniques
An Approach to Detecting Writing Styles Based on Clustering Techniques
ambekarshweta25
 
PPT on GRP pipes manufacturing and testing
PPT on GRP pipes manufacturing and testingPPT on GRP pipes manufacturing and testing
PPT on GRP pipes manufacturing and testing
anoopmanoharan2
 
digital fundamental by Thomas L.floydl.pdf
digital fundamental by Thomas L.floydl.pdfdigital fundamental by Thomas L.floydl.pdf
digital fundamental by Thomas L.floydl.pdf
drwaing
 
Hybrid optimization of pumped hydro system and solar- Engr. Abdul-Azeez.pdf
Hybrid optimization of pumped hydro system and solar- Engr. Abdul-Azeez.pdfHybrid optimization of pumped hydro system and solar- Engr. Abdul-Azeez.pdf
Hybrid optimization of pumped hydro system and solar- Engr. Abdul-Azeez.pdf
fxintegritypublishin
 
Governing Equations for Fundamental Aerodynamics_Anderson2010.pdf
Governing Equations for Fundamental Aerodynamics_Anderson2010.pdfGoverning Equations for Fundamental Aerodynamics_Anderson2010.pdf
Governing Equations for Fundamental Aerodynamics_Anderson2010.pdf
WENKENLI1
 
Modelagem de um CSTR com reação endotermica.pdf
Modelagem de um CSTR com reação endotermica.pdfModelagem de um CSTR com reação endotermica.pdf
Modelagem de um CSTR com reação endotermica.pdf
camseq
 
Fundamentals of Electric Drives and its applications.pptx
Fundamentals of Electric Drives and its applications.pptxFundamentals of Electric Drives and its applications.pptx
Fundamentals of Electric Drives and its applications.pptx
manasideore6
 
Literature Review Basics and Understanding Reference Management.pptx
Literature Review Basics and Understanding Reference Management.pptxLiterature Review Basics and Understanding Reference Management.pptx
Literature Review Basics and Understanding Reference Management.pptx
Dr Ramhari Poudyal
 
NUMERICAL SIMULATIONS OF HEAT AND MASS TRANSFER IN CONDENSING HEAT EXCHANGERS...
NUMERICAL SIMULATIONS OF HEAT AND MASS TRANSFER IN CONDENSING HEAT EXCHANGERS...NUMERICAL SIMULATIONS OF HEAT AND MASS TRANSFER IN CONDENSING HEAT EXCHANGERS...
NUMERICAL SIMULATIONS OF HEAT AND MASS TRANSFER IN CONDENSING HEAT EXCHANGERS...
ssuser7dcef0
 
Sachpazis:Terzaghi Bearing Capacity Estimation in simple terms with Calculati...
Sachpazis:Terzaghi Bearing Capacity Estimation in simple terms with Calculati...Sachpazis:Terzaghi Bearing Capacity Estimation in simple terms with Calculati...
Sachpazis:Terzaghi Bearing Capacity Estimation in simple terms with Calculati...
Dr.Costas Sachpazis
 
Planning Of Procurement o different goods and services
Planning Of Procurement o different goods and servicesPlanning Of Procurement o different goods and services
Planning Of Procurement o different goods and services
JoytuBarua2
 
KuberTENes Birthday Bash Guadalajara - K8sGPT first impressions
KuberTENes Birthday Bash Guadalajara - K8sGPT first impressionsKuberTENes Birthday Bash Guadalajara - K8sGPT first impressions
KuberTENes Birthday Bash Guadalajara - K8sGPT first impressions
Victor Morales
 
NO1 Uk best vashikaran specialist in delhi vashikaran baba near me online vas...
NO1 Uk best vashikaran specialist in delhi vashikaran baba near me online vas...NO1 Uk best vashikaran specialist in delhi vashikaran baba near me online vas...
NO1 Uk best vashikaran specialist in delhi vashikaran baba near me online vas...
Amil Baba Dawood bangali
 

Recently uploaded (20)

Technical Drawings introduction to drawing of prisms
Technical Drawings introduction to drawing of prismsTechnical Drawings introduction to drawing of prisms
Technical Drawings introduction to drawing of prisms
 
Tutorial for 16S rRNA Gene Analysis with QIIME2.pdf
Tutorial for 16S rRNA Gene Analysis with QIIME2.pdfTutorial for 16S rRNA Gene Analysis with QIIME2.pdf
Tutorial for 16S rRNA Gene Analysis with QIIME2.pdf
 
AKS UNIVERSITY Satna Final Year Project By OM Hardaha.pdf
AKS UNIVERSITY Satna Final Year Project By OM Hardaha.pdfAKS UNIVERSITY Satna Final Year Project By OM Hardaha.pdf
AKS UNIVERSITY Satna Final Year Project By OM Hardaha.pdf
 
14 Template Contractual Notice - EOT Application
14 Template Contractual Notice - EOT Application14 Template Contractual Notice - EOT Application
14 Template Contractual Notice - EOT Application
 
MCQ Soil mechanics questions (Soil shear strength).pdf
MCQ Soil mechanics questions (Soil shear strength).pdfMCQ Soil mechanics questions (Soil shear strength).pdf
MCQ Soil mechanics questions (Soil shear strength).pdf
 
Industrial Training at Shahjalal Fertilizer Company Limited (SFCL)
Industrial Training at Shahjalal Fertilizer Company Limited (SFCL)Industrial Training at Shahjalal Fertilizer Company Limited (SFCL)
Industrial Training at Shahjalal Fertilizer Company Limited (SFCL)
 
Understanding Inductive Bias in Machine Learning
Understanding Inductive Bias in Machine LearningUnderstanding Inductive Bias in Machine Learning
Understanding Inductive Bias in Machine Learning
 
An Approach to Detecting Writing Styles Based on Clustering Techniques
An Approach to Detecting Writing Styles Based on Clustering TechniquesAn Approach to Detecting Writing Styles Based on Clustering Techniques
An Approach to Detecting Writing Styles Based on Clustering Techniques
 
PPT on GRP pipes manufacturing and testing
PPT on GRP pipes manufacturing and testingPPT on GRP pipes manufacturing and testing
PPT on GRP pipes manufacturing and testing
 
digital fundamental by Thomas L.floydl.pdf
digital fundamental by Thomas L.floydl.pdfdigital fundamental by Thomas L.floydl.pdf
digital fundamental by Thomas L.floydl.pdf
 
Hybrid optimization of pumped hydro system and solar- Engr. Abdul-Azeez.pdf
Hybrid optimization of pumped hydro system and solar- Engr. Abdul-Azeez.pdfHybrid optimization of pumped hydro system and solar- Engr. Abdul-Azeez.pdf
Hybrid optimization of pumped hydro system and solar- Engr. Abdul-Azeez.pdf
 
Governing Equations for Fundamental Aerodynamics_Anderson2010.pdf
Governing Equations for Fundamental Aerodynamics_Anderson2010.pdfGoverning Equations for Fundamental Aerodynamics_Anderson2010.pdf
Governing Equations for Fundamental Aerodynamics_Anderson2010.pdf
 
Modelagem de um CSTR com reação endotermica.pdf
Modelagem de um CSTR com reação endotermica.pdfModelagem de um CSTR com reação endotermica.pdf
Modelagem de um CSTR com reação endotermica.pdf
 
Fundamentals of Electric Drives and its applications.pptx
Fundamentals of Electric Drives and its applications.pptxFundamentals of Electric Drives and its applications.pptx
Fundamentals of Electric Drives and its applications.pptx
 
Literature Review Basics and Understanding Reference Management.pptx
Literature Review Basics and Understanding Reference Management.pptxLiterature Review Basics and Understanding Reference Management.pptx
Literature Review Basics and Understanding Reference Management.pptx
 
NUMERICAL SIMULATIONS OF HEAT AND MASS TRANSFER IN CONDENSING HEAT EXCHANGERS...
NUMERICAL SIMULATIONS OF HEAT AND MASS TRANSFER IN CONDENSING HEAT EXCHANGERS...NUMERICAL SIMULATIONS OF HEAT AND MASS TRANSFER IN CONDENSING HEAT EXCHANGERS...
NUMERICAL SIMULATIONS OF HEAT AND MASS TRANSFER IN CONDENSING HEAT EXCHANGERS...
 
Sachpazis:Terzaghi Bearing Capacity Estimation in simple terms with Calculati...
Sachpazis:Terzaghi Bearing Capacity Estimation in simple terms with Calculati...Sachpazis:Terzaghi Bearing Capacity Estimation in simple terms with Calculati...
Sachpazis:Terzaghi Bearing Capacity Estimation in simple terms with Calculati...
 
Planning Of Procurement o different goods and services
Planning Of Procurement o different goods and servicesPlanning Of Procurement o different goods and services
Planning Of Procurement o different goods and services
 
KuberTENes Birthday Bash Guadalajara - K8sGPT first impressions
KuberTENes Birthday Bash Guadalajara - K8sGPT first impressionsKuberTENes Birthday Bash Guadalajara - K8sGPT first impressions
KuberTENes Birthday Bash Guadalajara - K8sGPT first impressions
 
NO1 Uk best vashikaran specialist in delhi vashikaran baba near me online vas...
NO1 Uk best vashikaran specialist in delhi vashikaran baba near me online vas...NO1 Uk best vashikaran specialist in delhi vashikaran baba near me online vas...
NO1 Uk best vashikaran specialist in delhi vashikaran baba near me online vas...
 

UI-Router

  • 1. UI-Router The hero we need… Loc Nguyen
  • 2. • 6:30 - 7:00 – Food and networking • 7:00 - 7:05 – Announcements, LoanNow intro • 7:05 - 7:30 – Restangular Lightning Talk • 7:30 - 8:15 – UI-Router • 8:15 - 8:25 – Wrap up and raffle
  • 3. <ng-selfie /> • Multi-platform SW engineering geek => Java, Ruby, JavaScript, C#, Node • ~1.5 years of AngularJS experience => mostly freelancing • Preferred Ember at first! • Speaking at OC Java UG in October
  • 4. ngRoute :-( • Transitions by URL • Work-arounds to handle nested views • Directives • ngInclude • ngSwitch
  • 5. UI-Router (>^_^)> • Transitions by state rather then by URL • Define and design states your application can be in • Nested states!
  • 6. States • Not all states need a URL, e.g. a modal, section expansion • Can configure in any order • Can configure across modules
  • 7. Nested States • Can configure child states before parents • A child state and its ancestors are active • Inherit parent dependencies using the resolve map
  • 8. UI-Router Services • $stateProvider – define state transitions • $state – transition to another state, check what the current state is • $stateParams – get route and query parameter values for the current state
  • 9. Simple State Configuration angular.module('helloApp').config(function($stateProvider) { $stateProvider.state('login', { url: '/login', templateUrl: 'views/login.html' }) });
  • 10. Diff with ngRoute angular.module('helloApp').config(function($stateProvider) { $stateProvider.state('login', { url: '/login', templateUrl: 'views/login.html' }) }); angular.module('helloApp').config(function($routeProvider) { $routeProvider.when('/login', { templateUrl: 'views/login.html' }) });
  • 11. Nested State Configuration angular.module('helloApp').config(function ($stateProvider) { $stateProvider.state('app', { template: '<html><body><header>you fancy</header>' + '<ui-view></ui-view></body></html>' }).state('app.login', { url: '/login', templateUrl: 'views/login.html' }); });
  • 12. Transitioning States $state.go('login'); angular.module('sampleApp').config(function ($stateProvider) { $stateProvider.state('acount', { url: '/account/:id?showDetails', templateUrl: 'views/account.html' }); }); $state.go('account', { id: 47, showDetails: true });
  • 13. In & Out Callbacks angular.module('sampleApp').config(function ($stateProvider) { $stateProvider.state('app.acount', { url: '/account/:id', templateUrl: 'views/account.html', onEnter: function () { console.log('Google Analytics, open modal etc'); }, onExit: function () { console.log('clean up, animate etc'); } }); });
  • 14. UI-Router Directives • uiSref – declarative link to a state • uiSrefActive – adds CSS classes when a state is active • uiView – where to place the state template
  • 15. UI-Router Directives • uiSref is UI-Router’s ngHref angular.module('sampleApp').config(function ($stateProvider) { $stateProvider.state('acount', { url: '/account/:id?showDetails', templateUrl: 'views/account.html' }); }); <a ui-sref="login">Login</a> <a ui-sref="account({ id: 47, showDetails: true })">Account</a>
  • 16. UI-Router Directives • uiView is UI-Router’s version of ngView • Tells UI-Router where to inject our views • Supports named views <html> <body> <header></header> <ui-view></ui-view> </body> </html>
  • 17. Named Views • More than one uiView in a template • Flexible and dynamic layouts <html> <body> <ui-view="header"></ui-view> <ui-view="sideNav"></ui-view> <ui-view="mainContent"></ui-view> </body> </html>
  • 18. Named Views angular.module('sampleApp').config(function ($stateProvider) { $stateProvider.state('login', { url: '/login', views: { 'header': { templateUrl: 'views/unauth-header.html' }, 'sideNav': { templateUrl: 'views/unauth-sidenav.html' }, 'content': { templateUrl: 'views/login.html' } } }); });
  • 19. Resolve & Controllers angular.module('sampleApp').config(function ($stateProvider) { $stateProvider.state('app.acount', { url: '/account/:id', templateUrl: 'views/account.html', resolve: { account: function ($http, $stateParams) { return $http.get('/api/account/' + $stateParams.id); } }, controller: function (account) { … } controller: 'AccountController' controller: ‘AccountController as account' }); });
  • 20. Nested Resolve & Controllers angular.module('sampleApp').config(function ($stateProvider) { $stateProvider.state('account', { url: '/account/:id', templateUrl: 'views/account.html', resolve: { account: function ($http, $stateParams) { … } } }) .state('account.details', { controller: function (account, DetailService) { … } }); });
  • 21. And more… • Regex parameters: url: “/contacts/{contactId:[0-9]{1,8}}" • $urlRouterProvider – watches $location and matches against URL configurations
  • 22. Resources • Egghead.io UI-Router Cheat sheet: http://goo.gl/ZcL0dv • UI-Router at CincyNG meetup: https://www.youtube.com/watch?v=lBqiZSemrqg • UI-Router extras: https://github.com/christopherthielen/ui-router-extras
  • 23. Didn't win? Get a HUGE discount on the course by visiting: http://tinyurl.com/AngularJSJumpstart