Advertisement
Guest User

Untitled

a guest
Jun 23rd, 2016
98
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.99 KB | None | 0 0
  1. myApp.controller('login', ['$scope','$rootScope', '$location', '$window', 'authenticate', '$http', '$cookieStore',function($scope, $rootScope, $location, $window, authenticate, $http, $cookieStore) {
  2. $scope.alert = '';
  3. $scope.login = function(){
  4. authenticate.login($scope.login.username, $scope.login.password).then(function(response){
  5. alert("Inside controller"+JSON.stringify(response));
  6. });
  7. }
  8. }]);
  9.  
  10. myApp.factory('authenticate',['$http', '$filter', '$cookieStore', '$rootScope', '$window', '$q',
  11. function($http, $filter, $cookieStore, $rootScope, $window, $q) {
  12. var data = "";
  13. var deferred = $q.defer();
  14. return {
  15. login: function(userName,password){
  16. $http.post('user/serverside/authentication.php',{username: userName, password: password})
  17. .then(function(response){
  18. deferred.resolve(response.data);
  19. alert("FACTORY"+JSON.stringify(response));
  20. });
  21. return deferred.promise;
  22. }
  23. }
  24. }]);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement