Advertisement
Guest User

Untitled

a guest
May 19th, 2016
84
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.99 KB | None | 0 0
  1. ------------------ ROOTING
  2.  
  3. myModule.config(function($routeProvider, $httpProvider){
  4. $routeProvider.
  5. when('/',{
  6. templateUrl: 'home.html',
  7. controller: 'HomeCtrl',
  8. controllerAs: 'controller'
  9. }).
  10. when('/login',{
  11. templateUrl: 'login.html',
  12. controller: 'NavCtrl',
  13. controllerAs: 'controller'
  14. }).
  15. when('/inscription',{
  16. templateUrl: 'inscription.html',
  17. controller: 'InscriptionCtrl',
  18. controllerAs: 'controller'
  19. }).
  20. otherwise({
  21. redirectTo: '/'
  22. });
  23.  
  24. $httpProvider.defaults.headers.common["X-Requested-With"] = 'XMLHttpRequest';
  25. });
  26.  
  27.  
  28.  
  29. -------------------------- CONTROLLER
  30.  
  31. myModule.controller('InscriptionCtrl',function($location, $http){
  32.  
  33. var self = this;
  34.  
  35. self.credentials = {};
  36.  
  37. self.register = function(credentials){
  38.  
  39. if(credentials != null){
  40. alert(credentials.username);
  41. } else{
  42. alert("credentials is null snif");
  43. }
  44.  
  45. var FormInscriptionDto = credentials ? {login : credentials.username, password : credentials.password} : {};
  46.  
  47. $http.post('/register-user', FormInscriptionDto).then(
  48. function(response){
  49. alert("wok");
  50. },
  51. function(){
  52. alert("werror");
  53. }
  54. );
  55. };
  56.  
  57. });
  58.  
  59.  
  60. ------------------------------- INSCRIPTIOnN.HTML
  61.  
  62. <article>
  63. <div class="alert alert-danger" ng-show="controller.error">
  64. There was a problem register in. Please try again.
  65. </div>
  66.  
  67. <form role="form" ng-submit="controller.register()">
  68.  
  69. <div class="form-group">
  70. <label for="username">Username:</label>
  71. <input type="text" class="form-control" id="username" name="username" ng-model="controller.credentials.username"/>
  72. </div>
  73.  
  74. <div class="form-group">
  75. <label for="password">Password:</label>
  76. <input type="password" class="form-control" id="password" name="password" ng-model="controller.credentials.password"/>
  77. </div>
  78.  
  79. <button type="submit" class="btn btn-primary">Submit</button>
  80.  
  81. </form>
  82.  
  83. </article>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement