Guest User

Untitled

a guest
Apr 2nd, 2017
70
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.56 KB | None | 0 0
  1. <form ng-submit="ctrl.loginUser()" name="myLoginForm">
  2. <div class="form-group">
  3. <label>Username</label>
  4. <input type="text" name="uname" class="form-control" ng-model="ctrl.loginuser.username" required>
  5. </div>
  6.  
  7. <div class="form-group">
  8. <label>Password</label>
  9. <input type="password" name="pwd" class="form-control" ng-model="ctrl.loginuser.password" required>
  10. </div>
  11.  
  12. <input type="submit" value="Login">
  13. </form>
  14.  
  15. angular.module("BaseApp", [])
  16. .config(['$httpProvider', function($httpProvider) {
  17. $httpProvider.defaults.xsrfCookieName = 'csrftoken';
  18. $httpProvider.defaults.xsrfHeaderName = 'X-CSRFToken';
  19. }])
  20.  
  21. .config(['$locationProvider', function($locationProvider){
  22. $locationProvider.html5Mode(true);
  23. }])
  24.  
  25. self.loginUser = function(loginuser) {
  26. return $http.post("/custom-api-auth/login", loginuser)
  27. .then(function(response) {
  28. console.log('here');
  29. $location.url("/test");
  30. });
  31. };
  32.  
  33. $stateProvider.state('test', {
  34. resolve:{
  35.  
  36. // Example using function with simple return value.
  37. // Since it's not a promise, it resolves immediately.
  38. simpleObj: function(){
  39. return {value: 'simple!'};
  40. },
  41.  
  42. // Example using function with returned promise.
  43. // This is the typical use case of resolve.
  44. // You need to inject any services that you are
  45. // using, e.g. $http in this example
  46. promiseObj: function($http){
  47. // $http returns a promise for the url data
  48. return $http({method: 'GET', url: '/someUrl'});
  49. },
  50.  
  51.  
  52.  
  53. },
Advertisement
Add Comment
Please, Sign In to add comment