Advertisement
Guest User

Untitled

a guest
Jan 17th, 2017
94
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.14 KB | None | 0 0
  1. angular.module('auction', ['ngRoute'])
  2. .config(['$routeProvider', function($routeProvider) {
  3. var title = function (page) {
  4. return page + ' | Auction';
  5. };
  6.  
  7. $routeProvider
  8. .when('/', {
  9. templateUrl: 'views/home.html',
  10. controller: 'HomeController',
  11. controllerAs: 'ctrl',
  12. title: title('Home')
  13. })
  14. .when('/search', {
  15. templateUrl: 'views/search.html',
  16. controller: 'SearchController',
  17. controllerAs: 'ctrl',
  18. title: title('Search')
  19. })
  20. .when('/product/:productId', {
  21. templateUrl: 'views/product.html',
  22. controller: 'ProductController',
  23. controllerAs: 'ctrl',
  24. title: title('Product Details'),
  25. resolve: {
  26. product: ['$route', 'ProductService', function ($route, productService) {
  27. var productId = parseInt($route.current.params.productId);
  28. return productService.getProductById(productId);
  29. }]
  30. }
  31. })
  32. .otherwise({
  33. redirectTo: '/'
  34. });
  35. }])
  36. .run(['$rootScope', function ($rootScope) {
  37. $rootScope.$on('$routeChangeSuccess', function (event, currentRoute) {
  38. $rootScope.pageTitle = currentRoute.title;
  39. });
  40. }]);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement