Advertisement
Guest User

Untitled

a guest
Oct 15th, 2016
85
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 4.40 KB | None | 0 0
  1. .config(function($stateProvider, $urlRouterProvider) {
  2. $stateProvider
  3.  
  4. .state('app', {
  5. url: '/app',
  6. abstract: true,
  7. templateUrl: 'templates/menu.html'
  8. })
  9.  
  10. .state('app.login', {
  11. url: '/login',
  12. views: {
  13. 'menuContent': {
  14. templateUrl: 'templates/login.html',
  15. controller: 'AppCtrl'
  16. }
  17. },
  18. authenticate: false
  19. })
  20.  
  21. .state('app.search', {
  22. url: '/search',
  23. views: {
  24. 'menuContent': {
  25. templateUrl: 'templates/search.html',
  26. controller: 'mainCtrl'
  27. }
  28. }
  29. })
  30.  
  31. .state('app.browse', {
  32. url: '/browse',
  33. views: {
  34. 'menuContent': {
  35. templateUrl: 'templates/browse.html',
  36. controller: 'mainCtrl'
  37. }
  38. }
  39. })
  40. .state('app.playlists', {
  41. url: '/playlists',
  42. views: {
  43. 'menuContent': {
  44. templateUrl: 'templates/playlists.html',
  45. controller: 'PlaylistsCtrl'
  46. }
  47. }
  48. })
  49.  
  50. .state('app.snapshot', {
  51. url: '/snapshot',
  52. views: {
  53. 'menuContent': {
  54. templateUrl: 'templates/snapshot.html'
  55. }
  56. }
  57. })
  58.  
  59. .state('app.callqueues', {
  60. url: '/callqueues',
  61. views: {
  62. 'menuContent': {
  63. templateUrl: 'templates/callqueues.html'
  64. }
  65. }
  66. })
  67.  
  68. .state('app.single', {
  69. url: '/playlists/:playlistId',
  70. views: {
  71. 'menuContent': {
  72. templateUrl: 'templates/playlist.html',
  73. controller: 'PlaylistCtrl'
  74. }
  75. }
  76. });
  77. // if none of the above states are matched, use this as the fallback
  78. // $urlRouterProvider.otherwise('/app/search');
  79. $urlRouterProvider.otherwise('/app/login');
  80. });
  81.  
  82. angular.module('starter.controllers', [])
  83.  
  84. .controller('AppCtrl', function($scope, $ionicModal, $timeout, $location, $http, $log, $state) {
  85.  
  86. // With the new view caching in Ionic, Controllers are only called
  87. // when they are recreated or on app start, instead of every page change.
  88. // To listen for when this page is active (for example, to refresh data),
  89. // listen for the $ionicView.enter event:
  90. //$scope.$on('$ionicView.enter', function(e) {
  91. //});
  92.  
  93. // Form data for the login modal
  94. $scope.loginData = {};
  95.  
  96. // Create the login modal that we will use later
  97. // $ionicModal.fromTemplateUrl('templates/login.html', {
  98. // scope: $scope
  99. // }).then(function(modal) {
  100. // $scope.modal = modal;
  101. // });
  102.  
  103. // Triggered in the login modal to close it
  104. // $scope.closeLogin = function() {
  105. // $scope.modal.hide();
  106. // };
  107.  
  108. // Open the login modal
  109. // $scope.login = function() {
  110. // $scope.modal.show();
  111. // };
  112.  
  113. $scope.chartConfig = {
  114. options: {
  115. chart: {
  116. type: 'bar'
  117. }
  118. },
  119. series: [{
  120. data: [10, 15, 12, 8, 7]
  121. }],
  122. title: {
  123. text: 'Hello'
  124. },
  125.  
  126. loading: false
  127. };
  128.  
  129. // Perform the login action when the user submits the login form
  130. $scope.doLogin = function() {
  131. console.log('Doing login', $scope.loginData);
  132. var username = $scope.loginData.name;
  133. var password = $scope.loginData.password;
  134. console.log("username" + $scope.loginData.name);
  135. if (username == "admin@as" && password == "admin") {
  136. console.log("if part");
  137. $location.path("#/app/search");
  138. } else {
  139. console.log("error");
  140. // $("#errorpwd").css({"display":"block"});
  141. // $scope.message = "Error";
  142. // $scope.messagecolor = "alert alert-danger";
  143. }
  144. // Simulate a login delay. Remove this and replace with your login
  145. // code if using a login system
  146. // $timeout(function() {
  147. // $scope.closeLogin();
  148. // }, 1000);
  149. };
  150. })
  151.  
  152. <ion-view view-title="Login" name="login-view">
  153. <ion-header-bar class="bar bar-header bar-positive">
  154. <h1 class="title">Login</h1>
  155. <!--<button class="button button-clear button-primary icon-left ion-close-circled" ng-click="modal.hide()"></button>-->
  156. </ion-header-bar>
  157. <ion-content>
  158. <form ng-submit="doLogin()">
  159. <div class="list">
  160. <label class="item item-input">
  161. <span class="input-label">Username</span>
  162. <input type="text" ng-model="loginData.name">
  163. </label>
  164. <label class="item item-input">
  165. <span class="input-label">Password</span>
  166. <input type="password" ng-model="loginData.password">
  167. </label>
  168. <label class="item">
  169. <button nav-clear class="button button-block button-positive" type="submit">Log in</button>
  170. </label>
  171. </div>
  172. </form>
  173. </ion-content>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement