SlideShare a Scribd company logo
Exploring routing options
Routing is mandatory.
For an angular app, we can choose between
the official ngRoute, or the popular ui-router.
In this talk i will introduce you with both of
them so you can choose what's fits your
needs.
nirkaufman@gmail.com
Spoiler!
In the end of this talk you will probably choose
to use ui-router for your project.
nirkaufman@gmail.com
What's the plan?
- Exploring the modules core features and
API.
- Asking questions & getting answers
but most important..
nirkaufman@gmail.com
Seeing it in Action!
Walking through a working demo project.
find the github link in the last slide
nirkaufman@gmail.com
ngRoute
Used to be baked into Angular core,
separated into it`s own module in version 1.2.
Provides a lot of functionality we expected
from a routing system.
nirkaufman@gmail.com
Installation
nirkaufman@gmail.com
use bower (or download manually) the angular-route.js file.
Make sure to load the module after angular.
specify ngRoute as a dependency for your module
$ bower install angular-route
<script src="angular.js"> </script>
<script src="angular-route.js"> </script>
angular.module('app', ['ngRoute']);
Simple route
nirkaufman@gmail.com
angular.module('app', ['ngRoute'])
.config(function ($routeProvider) {
$routeProvider
.when('/home',{ templateUrl: ‘views/home.html’ })
.when('/user',{ templateUrl: ‘views/user.html’ })
.otherwise({ template: “<div>NOT FOUND!</div>” })
In the config section of our module, we use the $routeProvider to map url`s to the
desired views. the most basic route should include an HTML template to render.
Navigate & Display Templates
nirkaufman@gmail.com
<ng-view onload=”fn()”></ng-view>
Our template will be rendered between the ng-view tags. this directive will create a
new child scope for the template. we can pass a function to the onload attribute.
ngRouter Support only one ngView per Application!
We can display the requested from html using <a> tags, or from javaScript using the
$location service:
function UserController ($location) {
$location.path(‘/admin’)}
Controllers & Parameters
nirkaufman@gmail.com
we can assign a controller to the view, and access the route parameters by injecting
the $routeParams service to our controller
.when('/user/:id,{
templateUrl: ‘views/user.html’,
controller: ‘UserController’ })
function UserController ($routeParams) {
$routeParams.id // 5234 }
http://www.yourApp.com/user/5234
Attaching custom data
nirkaufman@gmail.com
We can extend the route object to include extra data that we might need.
.when('/admin,{
templateUrl: ‘views/user.html’,
controller: ‘UserController’,
permissions: {level : ‘admin’, key: ‘23f’}
})
...
function UserController ($route) {
permissions = $route.current.permissions
}
Using resolve
nirkaufman@gmail.com
We can define a map of factory functions that will be resolved, and injected to our
controller.. if any of them is a promise, the route will hold until the resolved. it can be
used to load additional resources on demand or fetching data from a remote server.
.when('/admin,{
templateUrl: ‘views/user.html’,
controller: ‘UserController’,
resolve: {data: function() {return “info”} }
})
function UserController (data) {...}
Route LIfe cycle & events
nirkaufman@gmail.com
Url
Requested
$routeChangeStart
$routeChangeError
$routeChangeSuccess
ng-view kicks in$viewContentLoaded
onload function
ngView in Action
nirkaufman@gmail.com
$routeChangeSucsses
broadcasted
create New Scope
destroy last scope,
remove the last template
Link the new Template
with the new Scope
Link the controller
Emit
$viewContentLoaded
run the onload function
Things we didn't cover
nirkaufman@gmail.com
● $locationProvider - configure how the application deep linking paths are
stored (enable HTML5 mode, and define an hash prefix)
● $location - Represents the URL object as a set of methods (protocol,
host, port, path, search, hash)
● $route.reload() - a method that reloads the current view be causing the
ng-view directive to create new child scope and re-instantiate the
controller
● ngView autoscroll - calling to the $anchorScroll service
https://docs.angularjs.org/api/ngRoute/service/$route
UI Router
UI Router is a routing system for AngularJS
that based around the concept of states which
may optionally have routes, as well as other
behaviours.
nirkaufman@gmail.com
Define: state.
❏ a ‘place’ in the application in terms of UI
and navigation.
❏ a state describes what the UI looks like and
does at that place.
nirkaufman@gmail.com
Installation
use bower (or download manually) the angular-ui-router.js file.
Make sure to load the module after angular.
specify ui.router as a dependency for your module
nirkaufman@gmail.com
$ bower install angular-ui-router
<script src="angular.js"> </script>
<script src="angular-ui-router.js"> </script>
angular.module('app', ['ui.router']);
Simple State
nirkaufman@gmail.com
angular.module('app', ['ngRoute'])
.config(function ($stateProvider) {
$stateProvider
.state('home',{
url: ‘/home.html’,
templateUrl: ‘views/home.html’
})
In the config section of our module, we use the $stateProvider to define a state
object and give it a name
Navigate & Display Templates
nirkaufman@gmail.com
<ui-view> </ui-view>
Our template will be rendered between the ui-view tags.
ngRouter Support multiply ui-views per application!
We can display the requested from html using <a ui-sref=’stateName’> tags with
the or using the $state service method:
function UserController ($state) {
$state.go(‘home’)}
Controllers & Parameters
nirkaufman@gmail.com
just like $routeProvider, we can assign a controller to the state, and access the state
parameters by injecting the $stateParams service to our controller
.state('user,{
url: ‘/user/:id’
templateUrl: ‘views/user.html’,
controller: ‘UserController’ })
function UserController ($stateParams) {
$stateParams.id // 5234 }
http://www.yourApp.com/user/5234
Attaching custom data
nirkaufman@gmail.com
Another powerful feature is the ability to display different views in parallel:
.state('home',{
controller: ‘HomeController’
data : {
level: ‘admin’
}}
...
function HomeController ($state) {
data = $state.current.data
}
Nested Views
nirkaufman@gmail.com
One of the powerful features of ui router is the ability to define nested views:
$stateProvider
.state('home',{
url: ‘/home’,
templateUrl: ‘views/home.html’
})
.state('home.subsection,{
url: ‘/subsection’,
templateUrl: ‘views/section.html’
})
Named Views
nirkaufman@gmail.com
Another powerful feature is the ability to display different views in parallel:
$stateProvider
.state('home',{
views: {
"": { template: "<h1>HELLO!</h1>" },
"sidebar": { template: "<sidebar/>" },
"footer": { template: "<data_thing/>" }}...
index.html:
<div ui-view></div>
<div ui-view="sidebar"></div>
<div ui-view="footer"></div>
State Callbacks
nirkaufman@gmail.com
We can optionally define two callbacks to the state object, that will be fired when a
state beacom active or inactive, the callbacks can access to the resolved attributes
.state('home',{
resolve : { user: function () {...} }
onEnter : function (user) {},
onExit : function (user) {}
}
State LIfe cycle & events
nirkaufman@gmail.com
state
Requested
$stateChangeStart
$stateChangeError
$stateChangeSucsses
ui-view kicks in
$viewContentLoaded onload function Done!
$stateNotFound
Things we didn't cover
nirkaufman@gmail.com
● $state API - The $state service contain more methods beside go that we
take advantage of
● $templateFactory- a utility for defining templates in different ways
● state inheritance - child states inherited the resolves from their parent
state
● abstract - we can define an abstract template that cannot be directly
activated, but can use as a wrapper for our views
● ui-sref-active - directive that adds class when state is active
● much more...
http://angular-ui.github.io/ui-router/site/#/api
Summary
you will probably choose to use ui-router for
your project. basically because it supports
everything the normal ngRoute can do, as well
of as many extra features and functions that is
crucial for large scale applications.
nirkaufman@gmail.com
Migrating to ui-router
nirkaufman@gmail.com
if you are allready use ngRoute, you can start by replacing your routes with simple
states for a good start:
$stateProvider
.state('home',{
url: ‘/home’,
templateUrl: ‘home.html’
})
$routeProvider
.when('/home',{
templateUrl: ‘home.html’
})
<a href=”#/home”>Home</a> <a ui-sref=”home”>Home</a>
$location.url(‘/home’) $state.go(‘home’)
Grab the code:
https://github.com/nirkaufman/angularjs-routing-demo
nirkaufman@gmail.com
il.linkedin.com/in/nirkaufman/
Thank You!
nirkaufman@gmail.com

More Related Content

PDF
JavaScript - Chapter 10 - Strings and Arrays
PDF
jQuery Tutorial For Beginners | Developing User Interface (UI) Using jQuery |...
PPTX
PPTX
Angular 2.0 Dependency injection
PPT
JQuery introduction
PPTX
Angular Data Binding
PPTX
PDF
Web Development with Python and Django
JavaScript - Chapter 10 - Strings and Arrays
jQuery Tutorial For Beginners | Developing User Interface (UI) Using jQuery |...
Angular 2.0 Dependency injection
JQuery introduction
Angular Data Binding
Web Development with Python and Django

What's hot (20)

PPTX
Ajax ppt - 32 slides
PPTX
AngularJS Directives
PDF
Asynchronous JavaScript Programming with Callbacks & Promises
PDF
Java Deserialization Vulnerabilities - The Forgotten Bug Class (DeepSec Edition)
PDF
07 java collection
PDF
ORM Injection
KEY
Web application development with Django framework
PDF
Deep Dive Java 17 Devoxx UK
PPT
ADO.NET
PDF
Lambda Expressions in Java | Java Lambda Tutorial | Java Certification Traini...
PPT
JavaScript Tutorial
PPTX
Java 8 Lambda and Streams
PPTX
What Is Express JS?
PDF
HTTP Request and Response Structure
PPTX
jQuery PPT
PPSX
Spring - Part 1 - IoC, Di and Beans
PDF
Java 8 Lambda Built-in Functional Interfaces
PDF
Python programming : Strings
PPT
PPTX
jQuery
Ajax ppt - 32 slides
AngularJS Directives
Asynchronous JavaScript Programming with Callbacks & Promises
Java Deserialization Vulnerabilities - The Forgotten Bug Class (DeepSec Edition)
07 java collection
ORM Injection
Web application development with Django framework
Deep Dive Java 17 Devoxx UK
ADO.NET
Lambda Expressions in Java | Java Lambda Tutorial | Java Certification Traini...
JavaScript Tutorial
Java 8 Lambda and Streams
What Is Express JS?
HTTP Request and Response Structure
jQuery PPT
Spring - Part 1 - IoC, Di and Beans
Java 8 Lambda Built-in Functional Interfaces
Python programming : Strings
jQuery
Ad

Viewers also liked (20)

PDF
ui-router and $state
PDF
Angular JS Routing
PPTX
UI-Router
PPTX
Dive into AngularJS Routing
PDF
Redux with angular 2 - workshop 2016
PDF
AngularJS performance & production tips
PPTX
SMS based train ticket booking - Customer Education Presentation
DOCX
How routing works in angular js
PDF
Webpack and angularjs
PDF
AngularJS - Services
PDF
Ui router
PDF
Data Structures in javaScript 2015
PDF
Angular promises and http
PDF
redux and angular - up and running
PDF
Up & running with ECMAScript6
PDF
Solid angular
PDF
Angular js - 10 reasons to choose angularjs
PDF
Angular redux
PPTX
Sms pro - bulk SMS sending software
PPT
Web Config
ui-router and $state
Angular JS Routing
UI-Router
Dive into AngularJS Routing
Redux with angular 2 - workshop 2016
AngularJS performance & production tips
SMS based train ticket booking - Customer Education Presentation
How routing works in angular js
Webpack and angularjs
AngularJS - Services
Ui router
Data Structures in javaScript 2015
Angular promises and http
redux and angular - up and running
Up & running with ECMAScript6
Solid angular
Angular js - 10 reasons to choose angularjs
Angular redux
Sms pro - bulk SMS sending software
Web Config
Ad

Similar to Angular js routing options (20)

PDF
Angular Routing Tutorial | AngularJS vs Angular Router | Angular Training | E...
PPTX
ngNewRouter
PDF
Architecture, Auth, and Routing with uiRouter
DOCX
multiple views and routing
PPTX
UQ21CA642BA1-Unit-3-WAF-Class18-Introduction to Angular Routing.pptx
PDF
Beyond AngularJS: Best practices and more
PDF
Building Better Web Apps with Angular.js (SXSW 2014)
PDF
Angular Promises and Advanced Routing
PPTX
01 startoff angularjs
PPTX
AngularJS Fundamentals + WebAPI
PDF
Angular routing
PPTX
AngularJS One Day Workshop
PDF
AngularJS HTML Enhanced For Web Apps
PDF
CFUGbe talk about Angular JS
PPTX
Angular - a real world case study
PDF
AngularJS 101 - Everything you need to know to get started
PDF
ITB2015 - Crash Course in Ionic + AngularJS
PDF
Angularjs
PPTX
Angular Workshop_Sarajevo2
PPTX
AngularJs Superheroic JavaScript MVW Framework Services by Miracle Studios
Angular Routing Tutorial | AngularJS vs Angular Router | Angular Training | E...
ngNewRouter
Architecture, Auth, and Routing with uiRouter
multiple views and routing
UQ21CA642BA1-Unit-3-WAF-Class18-Introduction to Angular Routing.pptx
Beyond AngularJS: Best practices and more
Building Better Web Apps with Angular.js (SXSW 2014)
Angular Promises and Advanced Routing
01 startoff angularjs
AngularJS Fundamentals + WebAPI
Angular routing
AngularJS One Day Workshop
AngularJS HTML Enhanced For Web Apps
CFUGbe talk about Angular JS
Angular - a real world case study
AngularJS 101 - Everything you need to know to get started
ITB2015 - Crash Course in Ionic + AngularJS
Angularjs
Angular Workshop_Sarajevo2
AngularJs Superheroic JavaScript MVW Framework Services by Miracle Studios

More from Nir Kaufman (18)

PDF
Angular Dependency Injection
PDF
Angular Prestige: Less-known API and techniques
PDF
Angular CLI custom builders
PDF
Electronic music 101 for developers
PDF
Nestjs MasterClass Slides
PDF
Redux pattens - JSHeroes 2018
PDF
Angular EE - Special Workshop by Nir Kaufman
PDF
Boosting Angular runtime performance
PDF
Decorators in js
PDF
Styling recipes for Angular components
PDF
Introduction To Angular's reactive forms
PDF
Webstorm
PDF
Angular Pipes Workshop
PDF
How Angular2 Can Improve Your AngularJS Apps Today!
PDF
Angular2 workshop
PDF
Angular2 - getting-ready
PDF
Angularjs - Unit testing introduction
PDF
Angularjs - lazy loading techniques
Angular Dependency Injection
Angular Prestige: Less-known API and techniques
Angular CLI custom builders
Electronic music 101 for developers
Nestjs MasterClass Slides
Redux pattens - JSHeroes 2018
Angular EE - Special Workshop by Nir Kaufman
Boosting Angular runtime performance
Decorators in js
Styling recipes for Angular components
Introduction To Angular's reactive forms
Webstorm
Angular Pipes Workshop
How Angular2 Can Improve Your AngularJS Apps Today!
Angular2 workshop
Angular2 - getting-ready
Angularjs - Unit testing introduction
Angularjs - lazy loading techniques

Recently uploaded (20)

PDF
Diabetes mellitus diagnosis method based random forest with bat algorithm
PPTX
VMware vSphere Foundation How to Sell Presentation-Ver1.4-2-14-2024.pptx
PPTX
Cloud computing and distributed systems.
PDF
Spectral efficient network and resource selection model in 5G networks
PDF
Transforming Manufacturing operations through Intelligent Integrations
PPTX
Comunidade Salesforce São Paulo - Desmistificando o Omnistudio (Vlocity)
PDF
madgavkar20181017ppt McKinsey Presentation.pdf
PDF
Advanced IT Governance
PPT
“AI and Expert System Decision Support & Business Intelligence Systems”
PDF
CIFDAQ's Market Insight: SEC Turns Pro Crypto
PPTX
Effective Security Operations Center (SOC) A Modern, Strategic, and Threat-In...
PDF
cuic standard and advanced reporting.pdf
PDF
CIFDAQ's Market Wrap: Ethereum Leads, Bitcoin Lags, Institutions Shift
PDF
Reach Out and Touch Someone: Haptics and Empathic Computing
PDF
NewMind AI Weekly Chronicles - August'25 Week I
PPTX
Detection-First SIEM: Rule Types, Dashboards, and Threat-Informed Strategy
PDF
Review of recent advances in non-invasive hemoglobin estimation
PDF
Peak of Data & AI Encore- AI for Metadata and Smarter Workflows
PPTX
Big Data Technologies - Introduction.pptx
PPTX
Telecom Fraud Prevention Guide | Hyperlink InfoSystem
Diabetes mellitus diagnosis method based random forest with bat algorithm
VMware vSphere Foundation How to Sell Presentation-Ver1.4-2-14-2024.pptx
Cloud computing and distributed systems.
Spectral efficient network and resource selection model in 5G networks
Transforming Manufacturing operations through Intelligent Integrations
Comunidade Salesforce São Paulo - Desmistificando o Omnistudio (Vlocity)
madgavkar20181017ppt McKinsey Presentation.pdf
Advanced IT Governance
“AI and Expert System Decision Support & Business Intelligence Systems”
CIFDAQ's Market Insight: SEC Turns Pro Crypto
Effective Security Operations Center (SOC) A Modern, Strategic, and Threat-In...
cuic standard and advanced reporting.pdf
CIFDAQ's Market Wrap: Ethereum Leads, Bitcoin Lags, Institutions Shift
Reach Out and Touch Someone: Haptics and Empathic Computing
NewMind AI Weekly Chronicles - August'25 Week I
Detection-First SIEM: Rule Types, Dashboards, and Threat-Informed Strategy
Review of recent advances in non-invasive hemoglobin estimation
Peak of Data & AI Encore- AI for Metadata and Smarter Workflows
Big Data Technologies - Introduction.pptx
Telecom Fraud Prevention Guide | Hyperlink InfoSystem

Angular js routing options

  • 2. Routing is mandatory. For an angular app, we can choose between the official ngRoute, or the popular ui-router. In this talk i will introduce you with both of them so you can choose what's fits your needs. [email protected]
  • 3. Spoiler! In the end of this talk you will probably choose to use ui-router for your project. [email protected]
  • 4. What's the plan? - Exploring the modules core features and API. - Asking questions & getting answers but most important.. [email protected]
  • 5. Seeing it in Action! Walking through a working demo project. find the github link in the last slide [email protected]
  • 6. ngRoute Used to be baked into Angular core, separated into it`s own module in version 1.2. Provides a lot of functionality we expected from a routing system. [email protected]
  • 7. Installation [email protected] use bower (or download manually) the angular-route.js file. Make sure to load the module after angular. specify ngRoute as a dependency for your module $ bower install angular-route <script src="angular.js"> </script> <script src="angular-route.js"> </script> angular.module('app', ['ngRoute']);
  • 8. Simple route [email protected] angular.module('app', ['ngRoute']) .config(function ($routeProvider) { $routeProvider .when('/home',{ templateUrl: ‘views/home.html’ }) .when('/user',{ templateUrl: ‘views/user.html’ }) .otherwise({ template: “<div>NOT FOUND!</div>” }) In the config section of our module, we use the $routeProvider to map url`s to the desired views. the most basic route should include an HTML template to render.
  • 9. Navigate & Display Templates [email protected] <ng-view onload=”fn()”></ng-view> Our template will be rendered between the ng-view tags. this directive will create a new child scope for the template. we can pass a function to the onload attribute. ngRouter Support only one ngView per Application! We can display the requested from html using <a> tags, or from javaScript using the $location service: function UserController ($location) { $location.path(‘/admin’)}
  • 10. Controllers & Parameters [email protected] we can assign a controller to the view, and access the route parameters by injecting the $routeParams service to our controller .when('/user/:id,{ templateUrl: ‘views/user.html’, controller: ‘UserController’ }) function UserController ($routeParams) { $routeParams.id // 5234 } http://www.yourApp.com/user/5234
  • 11. Attaching custom data [email protected] We can extend the route object to include extra data that we might need. .when('/admin,{ templateUrl: ‘views/user.html’, controller: ‘UserController’, permissions: {level : ‘admin’, key: ‘23f’} }) ... function UserController ($route) { permissions = $route.current.permissions }
  • 12. Using resolve [email protected] We can define a map of factory functions that will be resolved, and injected to our controller.. if any of them is a promise, the route will hold until the resolved. it can be used to load additional resources on demand or fetching data from a remote server. .when('/admin,{ templateUrl: ‘views/user.html’, controller: ‘UserController’, resolve: {data: function() {return “info”} } }) function UserController (data) {...}
  • 13. Route LIfe cycle & events [email protected] Url Requested $routeChangeStart $routeChangeError $routeChangeSuccess ng-view kicks in$viewContentLoaded onload function
  • 14. ngView in Action [email protected] $routeChangeSucsses broadcasted create New Scope destroy last scope, remove the last template Link the new Template with the new Scope Link the controller Emit $viewContentLoaded run the onload function
  • 15. Things we didn't cover [email protected] ● $locationProvider - configure how the application deep linking paths are stored (enable HTML5 mode, and define an hash prefix) ● $location - Represents the URL object as a set of methods (protocol, host, port, path, search, hash) ● $route.reload() - a method that reloads the current view be causing the ng-view directive to create new child scope and re-instantiate the controller ● ngView autoscroll - calling to the $anchorScroll service https://docs.angularjs.org/api/ngRoute/service/$route
  • 16. UI Router UI Router is a routing system for AngularJS that based around the concept of states which may optionally have routes, as well as other behaviours. [email protected]
  • 17. Define: state. ❏ a ‘place’ in the application in terms of UI and navigation. ❏ a state describes what the UI looks like and does at that place. [email protected]
  • 18. Installation use bower (or download manually) the angular-ui-router.js file. Make sure to load the module after angular. specify ui.router as a dependency for your module [email protected] $ bower install angular-ui-router <script src="angular.js"> </script> <script src="angular-ui-router.js"> </script> angular.module('app', ['ui.router']);
  • 19. Simple State [email protected] angular.module('app', ['ngRoute']) .config(function ($stateProvider) { $stateProvider .state('home',{ url: ‘/home.html’, templateUrl: ‘views/home.html’ }) In the config section of our module, we use the $stateProvider to define a state object and give it a name
  • 20. Navigate & Display Templates [email protected] <ui-view> </ui-view> Our template will be rendered between the ui-view tags. ngRouter Support multiply ui-views per application! We can display the requested from html using <a ui-sref=’stateName’> tags with the or using the $state service method: function UserController ($state) { $state.go(‘home’)}
  • 21. Controllers & Parameters [email protected] just like $routeProvider, we can assign a controller to the state, and access the state parameters by injecting the $stateParams service to our controller .state('user,{ url: ‘/user/:id’ templateUrl: ‘views/user.html’, controller: ‘UserController’ }) function UserController ($stateParams) { $stateParams.id // 5234 } http://www.yourApp.com/user/5234
  • 22. Attaching custom data [email protected] Another powerful feature is the ability to display different views in parallel: .state('home',{ controller: ‘HomeController’ data : { level: ‘admin’ }} ... function HomeController ($state) { data = $state.current.data }
  • 23. Nested Views [email protected] One of the powerful features of ui router is the ability to define nested views: $stateProvider .state('home',{ url: ‘/home’, templateUrl: ‘views/home.html’ }) .state('home.subsection,{ url: ‘/subsection’, templateUrl: ‘views/section.html’ })
  • 24. Named Views [email protected] Another powerful feature is the ability to display different views in parallel: $stateProvider .state('home',{ views: { "": { template: "<h1>HELLO!</h1>" }, "sidebar": { template: "<sidebar/>" }, "footer": { template: "<data_thing/>" }}... index.html: <div ui-view></div> <div ui-view="sidebar"></div> <div ui-view="footer"></div>
  • 25. State Callbacks [email protected] We can optionally define two callbacks to the state object, that will be fired when a state beacom active or inactive, the callbacks can access to the resolved attributes .state('home',{ resolve : { user: function () {...} } onEnter : function (user) {}, onExit : function (user) {} }
  • 26. State LIfe cycle & events [email protected] state Requested $stateChangeStart $stateChangeError $stateChangeSucsses ui-view kicks in $viewContentLoaded onload function Done! $stateNotFound
  • 27. Things we didn't cover [email protected] ● $state API - The $state service contain more methods beside go that we take advantage of ● $templateFactory- a utility for defining templates in different ways ● state inheritance - child states inherited the resolves from their parent state ● abstract - we can define an abstract template that cannot be directly activated, but can use as a wrapper for our views ● ui-sref-active - directive that adds class when state is active ● much more... http://angular-ui.github.io/ui-router/site/#/api
  • 28. Summary you will probably choose to use ui-router for your project. basically because it supports everything the normal ngRoute can do, as well of as many extra features and functions that is crucial for large scale applications. [email protected]
  • 29. Migrating to ui-router [email protected] if you are allready use ngRoute, you can start by replacing your routes with simple states for a good start: $stateProvider .state('home',{ url: ‘/home’, templateUrl: ‘home.html’ }) $routeProvider .when('/home',{ templateUrl: ‘home.html’ }) <a href=”#/home”>Home</a> <a ui-sref=”home”>Home</a> $location.url(‘/home’) $state.go(‘home’)