Advertisement
Guest User

Untitled

a guest
Oct 4th, 2015
62
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.82 KB | None | 0 0
  1. var myApp = angular.module('myApp', ['ui.router']);
  2.  
  3. myApp.config(['$routeProvider','$locationProvider', '$httpProvider',
  4. function ($routeProvider, $locationProvider, $httpProvider) {
  5. $locationProvider.hashPrefix('!').html5Mode(true);
  6. $routeProvider
  7. .when('/NewOrder', {
  8. templateUrl: 'templates/NewOrder',
  9. controller: 'AddOrderController'
  10. }).when('/ShowOrders/:orderID', {
  11. templateUrl: function (params) {return '/templates/ShowOrders?orderID=' + params.orderID; },
  12. controller: 'ShowOrdersController'
  13. }).otherwise({
  14. redirectTo: '/ShowOrders'
  15. });
  16. }
  17. ]);
  18.  
  19. myApp.controller('AddOrderController', function ($scope) {
  20. $scope.message = 'This is the add new order controller screen';
  21. });
  22.  
  23. myApp.controller('ShowOrdersController', function ($scope,$routeParams) {
  24. $scope.message = 'This is the show orders controller';
  25. $scope.order_id = $routeParams.orderID;
  26. });
  27.  
  28. routes.IgnoreRoute("{resource}.axd/{*pathInfo}");
  29.  
  30. routes.MapRoute(
  31. name: "NewOrder",
  32. url: "templates/NewOrder",
  33. defaults: new { controller = "Templates", action = "AddOrder" });
  34.  
  35. routes.MapRoute(
  36. name: "ShowOrders",
  37. url: "templates/ShowOrders/{orderID}",
  38. defaults: new { controller = "Templates", action = "ShowOrders", orderID = "" });
  39.  
  40. routes.MapRoute(
  41. name: "Default",
  42. url: "{controller}/{action}/{id}",
  43. defaults: new { controller = "Home", action = "Index", id = UrlParameter.Optional }
  44. );
  45.  
  46. routes.MapRoute(
  47. name: "Defaults",
  48. url: "{*url}",
  49. defaults: new { controller = "Home", action = "Index", id = UrlParameter.Optional }
  50. );
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement