Advertisement
Guest User

Untitled

a guest
Mar 4th, 2015
182
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.49 KB | None | 0 0
  1. angular.module('inparty.controllers', [])
  2.  
  3. .controller('AppCtrl', function($scope, $ionicModal, $timeout) {
  4. // Form data for the login modal
  5. $scope.loginData = {};
  6.  
  7. // Create the login modal that we will use later
  8. $ionicModal.fromTemplateUrl('templates/login.html', {
  9. scope: $scope
  10. }).then(function(modal) {
  11. $scope.modal = modal;
  12. });
  13.  
  14. // Triggered in the login modal to close it
  15. $scope.closeLogin = function() {
  16. $scope.modal.hide();
  17. };
  18.  
  19. // Open the login modal
  20. $scope.login = function() {
  21. $scope.modal.show();
  22. };
  23.  
  24. // Perform the login action when the user submits the login form
  25. $scope.doLogin = function() {
  26. console.log('Doing login', $scope.loginData);
  27.  
  28. // Simulate a login delay. Remove this and replace with your login
  29. // code if using a login system
  30. $timeout(function() {
  31. $scope.closeLogin();
  32. }, 1000);
  33. };
  34. })
  35.  
  36. .controller('PlaylistsCtrl', function($scope,$http) {
  37. $scope.dados = Array();
  38.  
  39. $http.get("js/dados.php").success(function(data){
  40. $scope.dados = data.dados;
  41. console.log($scope.dados);
  42. }).error(function(data){
  43. alert("Error...");
  44. console.log(data);
  45. });
  46. })
  47.  
  48. .controller('PlaylistCtrl', function($scope, $stateParams) {
  49. var idParaEncontrar = $stateParams.id;
  50. console.log(idParaEncontrar);
  51. var objectoEncontrado = undefined;
  52.  
  53. for(var i = 0; i < $scope.dados.length: ++i){
  54. if($scope.dados[i].id === idParaEncontrar) {
  55. objectoEncontrado = $scope.dados[id];
  56. break;
  57. }
  58. }
  59. if(objectoEncontrado !== undefined) {
  60. console.log("objecto encontrado")
  61. }
  62. });
  63.  
  64. angular.module('inparty', ['ionic', 'inparty.controllers','ngRoute'])
  65.  
  66. .run(function($ionicPlatform) {
  67. $ionicPlatform.ready(function() {
  68. // Hide the accessory bar by default (remove this to show the accessory bar above the keyboard
  69. // for form inputs)
  70. if (window.cordova && window.cordova.plugins.Keyboard) {
  71. cordova.plugins.Keyboard.hideKeyboardAccessoryBar(true);
  72. }
  73. if (window.StatusBar) {
  74. // org.apache.cordova.statusbar required
  75. StatusBar.styleDefault();
  76. }
  77. });
  78. })
  79.  
  80. .config(function($stateProvider, $urlRouterProvider) {
  81. $stateProvider
  82.  
  83. .state('app', {
  84. url: "/app",
  85. abstract: true,
  86. templateUrl: "templates/menu.html",
  87. controller: 'AppCtrl'
  88. })
  89.  
  90. .state('app.search', {
  91. url: "/search",
  92. views: {
  93. 'menuContent': {
  94. templateUrl: "templates/search.html"
  95. }
  96. }
  97. })
  98.  
  99. .state('app.browse', {
  100. url: "/browse",
  101. views: {
  102. 'menuContent': {
  103. templateUrl: "templates/browse.html"
  104. }
  105. }
  106. })
  107. .state('app.playlists', {
  108. url: "/playlists",
  109. views: {
  110. 'menuContent': {
  111. templateUrl: "templates/playlists.html",
  112. controller: 'PlaylistsCtrl'
  113. }
  114. }
  115. })
  116.  
  117. .state('app.single', {
  118. url: "/playlists/:id",
  119. views: {
  120. 'menuContent': {
  121. templateUrl: "templates/playlist.html",
  122. controller: 'PlaylistCtrl'
  123. }
  124. }
  125. });
  126. // if none of the above states are matched, use this as the fallback
  127. $urlRouterProvider.otherwise('/app/playlists');
  128. });
  129.  
  130. var inpartyControllers = angular.module('inparty.controllers', []);
  131.  
  132. angular.module('inparty', ['ionic', 'inparty.controllers','ngRoute'])
  133. .run(function($ionicPlatform) {
  134. // Seu código continua aqui.
  135.  
  136. inpartyControllers
  137. .controller('AppCtrl', function($scope, $ionicModal, $timeout) {
  138. // Form data for the login modal
  139. $scope.loginData = {};
  140. // Seu código continua aqui.
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement