Advertisement
Guest User

Untitled

a guest
Aug 3rd, 2016
72
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 4.24 KB | None | 0 0
  1. <!DOCTYPE html>
  2. <html ng-app="myApp">
  3. <head>
  4. <meta charset="UTF-8">
  5. <meta name="viewport" content="width=device-width, initial-scale=1">
  6. <title></title>
  7.  
  8. <script src="https://ajax.googleapis.com/ajax/libs/jquery/2.2.2/jquery.min.js"></script>
  9. <script src="assets/lib/angular.min.js"></script>
  10. <script src="assets/lib/angular-route.min.js"></script>
  11. <script src="https://code.angularjs.org/1.3.0-rc.2/angular-messages.js"></script>
  12.  
  13. <script src="app/components/resetpassword/resetPasswordController.js"></script>
  14. <script src="app/app.js"></script>
  15. </head>
  16. <body>
  17. <div class="main" ng-view></div>
  18. </body>
  19. </html>
  20.  
  21. ( function () {
  22.  
  23. angular.module('myApp', [
  24. 'ngRoute',
  25. 'ngMessages',
  26. 'entreprenityApp.resetpassword'
  27. ])
  28.  
  29. .config(['$routeProvider', function($routeProvider) {
  30. $routeProvider
  31. .when('/resetpassword', {
  32. controller: 'ResetpasswordController',
  33. templateUrl: 'app/components/resetpassword/resetpasswordView.html',
  34. controllerAs: 'vm'
  35. })
  36. .otherwise({
  37. redirectTo: '/resetpassword'
  38. });
  39. }]);
  40.  
  41. (function() {
  42.  
  43. angular
  44. .module('myApp.resetpassword', ["ngMessages"])
  45.  
  46. .directive('compareTo', function() {
  47.  
  48. return {
  49. require: "ngModel",
  50. scope: {
  51. otherModelValue: "=compareTo"
  52. },
  53. link: function(scope, element, attributes, ngModel) {
  54.  
  55. ngModel.$validators.compareTo = function(modelValue) {
  56. return modelValue == scope.otherModelValue;
  57. };
  58.  
  59. scope.$watch("otherModelValue", function() {
  60. ngModel.$validate();
  61. });
  62. }
  63. };
  64.  
  65. })
  66. .controller('ResetpasswordController', function($scope, $http, $location) {
  67.  
  68. var vm = this;
  69. vm.message = "gg";
  70.  
  71. vm.user = {
  72. username: "",
  73. password: "",
  74. confirmPassword: ""
  75. };
  76.  
  77. vm.submit = function(isValid)
  78. {
  79. console.log("h");
  80. if (isValid)
  81. {
  82. vm.message = "Submitted " + vm.user.username;
  83. }
  84. else
  85. {
  86. vm.message = "There are still invalid fields below";
  87. }
  88. };
  89.  
  90. });
  91.  
  92. })();
  93.  
  94. })();
  95.  
  96. <div class="media-list">
  97.  
  98. <h3>{{ vm.message }}</h3>
  99. <form name="registrationForm" novalidate ng-submit="vm.submit(registrationForm.$valid)">
  100. <div class="form-group">
  101. <label>User Name</label>
  102. <input type="text" name="username" class="form-control" ng-model="vm.user.username" required />
  103. <div ng-messages="registrationForm.username.$error" ng-messages-include="app/common/messages.html"></div>
  104. </div>
  105. <div class="form-group">
  106. <label>Password</label>
  107. <input type="password" name="password" class="form-control" ng-model="vm.user.password" required />
  108. <div ng-messages="registrationForm.password.$error" ng-messages-include="app/common/messages.html"></div>
  109. </div>
  110. <div class="form-group">
  111. <label>Confirm Password</label>
  112. <input type="password" name="confirmPassword" class="form-control"
  113. ng-model="vm.user.confirmPassword"
  114. required compare-to="vm.user.password" />
  115. <div ng-messages="registrationForm.confirmPassword.$error" ng-messages-include="app/common/messages.html"></div>
  116. </div>
  117. <div class="form-group">
  118. <button type="submit" ng-disabled="form.$invalid" class="btn btn-primary">Change Password</button>
  119. </div>
  120. </form>
  121.  
  122. </div>
  123.  
  124. <div class="messages">
  125. <div ng-message="required">Required</div>
  126. <div ng-message="minlength">Too short</div>
  127. <div ng-message="maxlength">Too long</div>
  128. <div ng-message="email">Invalid email address</div>
  129. <div ng-message="compareTo">Must match the previous entry</div>
  130. </div>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement