Advertisement
Guest User

Untitled

a guest
Jan 11th, 2016
77
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.32 KB | None | 0 0
  1. <ion-header-bar align-title="center" class="bar-balanced">
  2. <h1 class="title">Onseral</h1>
  3. </ion-header-bar>
  4. <ion-view>
  5. <ion-content class="padding has-header">
  6. <ion-list>
  7. <ion-item>
  8. <input type="text" ng-model="username" placeholder="Username">
  9. </ion-item>
  10. <ion-item>
  11. <input type="password" ng-model="password" placeholder="Password">
  12. </ion-item>
  13. </ion-list>
  14.  
  15. <button nav-clear class="button button-block button-balanced" ng-click="LogIn()">Login</button>
  16. </ion-content>
  17. </ion-view>
  18.  
  19. angular.module('ionicApp.controllers', [])
  20. .controller('AppCtrl', function($scope) {
  21. })
  22.  
  23. .controller('LoginCtrl', function($scope, $state, $http, $ionicPopup) {
  24. $scope.LogIn = function() {
  25. var request = $http({
  26. method: "post",
  27. url: "http://www.webcentury.co.id/api/login.php",
  28. data: {
  29. username: $scope.username,
  30. password: $scope.password
  31. },
  32. headers: { 'Content-Type': 'application/x-www-form-urlencoded' }
  33. });
  34.  
  35. /*Successful HTTP post request or not */
  36.  
  37. request.success(function (data){
  38. //console.log(data);
  39. if (data == '1'){
  40. console.log('test success');
  41. }
  42. else {
  43. console.log('test failed');
  44. console.log($scope.username);
  45. }
  46. })
  47. }
  48. });
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement