Created
June 30, 2014 01:02
-
-
Save julianpoy/6f61dd3a17212fb35abe to your computer and use it in GitHub Desktop.
Comparison between routes and states
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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