app.js 3.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114
  1. // Ionic Starter App
  2. // angular.module is a global place for creating, registering and retrieving Angular modules
  3. // 'starter' is the name of this angular module example (also set in a <body> attribute in index.html)
  4. // the 2nd parameter is an array of 'requires'
  5. // 'starter.services' is found in services.js
  6. // 'starter.controllers' is found in controllers.js
  7. angular.module('starter', ['ionic', 'starter.controllers', 'starter.services', 'ngResource', 'underscore'])
  8. .run(function($ionicPlatform) {
  9. $ionicPlatform.ready(function() {
  10. // Hide the accessory bar by default (remove this to show the accessory bar above the keyboard
  11. // for form inputs)
  12. if (window.cordova && window.cordova.plugins && window.cordova.plugins.Keyboard) {
  13. cordova.plugins.Keyboard.hideKeyboardAccessoryBar(true);
  14. cordova.plugins.Keyboard.disableScroll(true);
  15. }
  16. if (window.StatusBar) {
  17. // org.apache.cordova.statusbar required
  18. StatusBar.styleDefault();
  19. }
  20. });
  21. })
  22. .config(function($stateProvider, $urlRouterProvider, $resourceProvider, $httpProvider) {
  23. // Ionic uses AngularUI Router which uses the concept of states
  24. // Learn more here: https://github.com/angular-ui/ui-router
  25. // Set up the various states which the app can be in.
  26. // Each state's controller can be found in controllers.js
  27. $stateProvider
  28. // setup an abstract state for the tabs directive
  29. .state('tab', {
  30. url: '/tab',
  31. abstract: true,
  32. templateUrl: 'templates/tabs.html'
  33. })
  34. // Each tab has its own nav history stack:
  35. .state('tab.dash', {
  36. url: '/dash',
  37. views: {
  38. 'tab-dash': {
  39. templateUrl: 'templates/tab-dash.html',
  40. controller: 'DashCtrl'
  41. }
  42. }
  43. })
  44. .state('tab.chats', {
  45. url: '/chats',
  46. views: {
  47. 'tab-chats': {
  48. templateUrl: 'templates/tab-chats.html',
  49. controller: 'ChatsCtrl'
  50. }
  51. }
  52. })
  53. .state('tab.chat-detail', {
  54. url: '/chats/:chatId',
  55. views: {
  56. 'tab-chats': {
  57. templateUrl: 'templates/chat-detail.html',
  58. controller: 'ChatDetailCtrl'
  59. }
  60. }
  61. })
  62. .state('tab.account', {
  63. url: '/account',
  64. views: {
  65. 'tab-account': {
  66. templateUrl: 'templates/tab-account.html',
  67. controller: 'AccountCtrl'
  68. }
  69. }
  70. })
  71. .state('tab.task-detail', {
  72. url: '/account/:id',
  73. views: {
  74. 'tab-account': {
  75. templateUrl: 'templates/task-detail.html',
  76. controller: 'TaskDetailCtrl'
  77. }
  78. }
  79. });
  80. // if none of the above states are matched, use this as the fallback
  81. $urlRouterProvider.otherwise('/tab/dash');
  82. $httpProvider.interceptors.push(function () {
  83. return {
  84. 'request': function (config) {
  85. config.url += (config.url.indexOf("?") === -1 ? "?" : "&") + "v=" + Date.now();
  86. return config;
  87. }
  88. };
  89. });
  90. $resourceProvider.defaults.stripTrailingSlashes = false;
  91. $resourceProvider.defaults.actions.update = {
  92. method: 'PUT',
  93. params: {
  94. id: "@id"
  95. }
  96. };
  97. $resourceProvider.defaults.actions.patch = {
  98. method: 'PATCH',
  99. };
  100. });