Skip to content

Instantly share code, notes, and snippets.

@julianpoy
Created June 30, 2014 01:02
Show Gist options
  • Save julianpoy/6f61dd3a17212fb35abe to your computer and use it in GitHub Desktop.
Save julianpoy/6f61dd3a17212fb35abe to your computer and use it in GitHub Desktop.
Comparison between routes and states
myApp.config(function($stateProvider) {
$stateProvider
.state('index', {
url: "",
views: {
"viewA": { template: "index.viewA" },
"viewB": { template: "index.viewB" }
}
})
.state('route1', {
url: "/route1",
views: {
"viewA": { template: "route1.viewA" },
"viewB": { template: "route1.viewB" }
}
})
.state('route2', {
url: "/route2",
views: {
"viewA": { template: "route2.viewA" },
"viewB": { template: "route2.viewB" }
}
})
});
vs
.config(function ($routeProvider) {
$routeProvider
.when('/', {
templateUrl: 'views/main.html',
controller: 'MainCtrl'
})
.when('/add', {
templateUrl: 'views/newcontact.html',
controller: 'NewcontactCtrl'
})
.when('/edit', {
templateUrl: 'views/editcontact.html',
controller: 'EditcontactCtrl'
})
.when('/delete', {
templateUrl: 'views/deletecontact.html',
controller: 'DeletecontactCtrl'
})
.when('/contact', {
templateUrl: 'views/contact.html',
controller: 'ContactCtrl'
})
.otherwise({
redirectTo: '/'
});
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment