Advertisement
Guest User

Untitled

a guest
Jan 14th, 2017
93
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.71 KB | None | 0 0
  1. /**
  2. * Created by bogdana on 1/14/17.
  3. */
  4. app.controller("loginController", function ($scope, $http) {
  5. $scope.user = {username: '', password: ''};
  6. $scope.onLogIn = function () {
  7. $http({
  8. method: 'POST',
  9. url: '/api/login',
  10. headers: {'Content-Type': 'application/x-www-form-urlencoded'},
  11. transformRequest: function(obj) {
  12. var str = [];
  13. for(var p in obj)
  14. str.push(encodeURIComponent(p) + "=" + encodeURIComponent(obj[p]));
  15. return str.join("&");
  16. },
  17. data: $scope.user
  18. }).then(function (data) {
  19. alert(data.username);
  20. });
  21. }
  22. });
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement