-
-
Save anonymous/f501a574ca67d4d0c2c3 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var myApp = angular.module('myApp', ['ngRoute', 'appControllers']); | |
myApp.config(['$routeProvider',function($routeProvider){ | |
$routeProvider.when('/meetings',{ | |
controller: 'MeetingsCtrl', | |
templateUrl: 'views/meeting.html' | |
}).when('/login',{ | |
controller: 'RegCtrl', | |
templateUrl: 'views/login.html' | |
}).when('/register',{ | |
controller: 'RegCtrl', | |
templateUrl: 'views/register.html' | |
}).otherwise({ | |
redirectTo:'/login', | |
controller: 'RegCtrl' | |
}) | |
}]); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var appControllers = angular.module('appControllers',['ngCookies']); | |
appControllers.controller('RegCtrl',['$scope', '$location','$http','$cookies', function($scope, $location, $http, $cookies){ | |
$scope.heading = 'Пожалуйста, заполните все поля'; | |
$scope.message = null; | |
$scope.error = null; | |
$scope.user={ | |
password:'', | |
email:'' | |
}; | |
$scope.login = function(user){ | |
$http({ | |
url: 'admin/login.php', | |
method: "POST", | |
data: 'login=' + user.email + '&password=' + user.password, | |
headers: {'Content-Type': 'application/x-www-form-urlencoded'} | |
}). | |
success(function(data, status, headers, config) { | |
console.log(data); | |
$cookies.put('currentUser', data); // here is the place where error occurs | |
}). | |
error(function(data, status, headers, config) { | |
}); | |
}; | |
}]); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!doctype html> | |
<html lang="en" ng-app="myApp"> | |
<head> | |
<meta charset="UTF-8"> | |
<meta name="viewport" content="width=device-width, user-scalable=no"> | |
<title>Angular Data</title> | |
<link rel="stylesheet" href="css/style.css"> | |
<script src="js/lib/angular/angular.min.js"></script> | |
<script src="js/lib/angular/angular-route.min.js"></script> | |
<script src="js/lib/angular/angular-animate.min.js"></script> | |
<script src="js/lib/angular/angular-cookies.js"></script> | |
<script src="js/appControllers.js"></script> | |
<script src="js/app.js"></script> | |
</head> | |
<body> | |
<header> | |
<nav class="cf" ng-include="'views/nav.html'"></nav> | |
</header> | |
<div class="page"> | |
<main class="cf" ng-view> | |
</main> | |
</div> | |
</body> | |
</html> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment