Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <!DOCTYPE html>
- <html ng-app="myApp">
- <head>
- <meta charset="UTF-8">
- <meta name="viewport" content="width=device-width, initial-scale=1">
- <title></title>
- <script src="https://ajax.googleapis.com/ajax/libs/jquery/2.2.2/jquery.min.js"></script>
- <script src="assets/lib/angular.min.js"></script>
- <script src="assets/lib/angular-route.min.js"></script>
- <script src="https://code.angularjs.org/1.3.0-rc.2/angular-messages.js"></script>
- <script src="app/components/resetpassword/resetPasswordController.js"></script>
- <script src="app/app.js"></script>
- </head>
- <body>
- <div class="main" ng-view></div>
- </body>
- </html>
- ( function () {
- angular.module('myApp', [
- 'ngRoute',
- 'ngMessages',
- 'entreprenityApp.resetpassword'
- ])
- .config(['$routeProvider', function($routeProvider) {
- $routeProvider
- .when('/resetpassword', {
- controller: 'ResetpasswordController',
- templateUrl: 'app/components/resetpassword/resetpasswordView.html',
- controllerAs: 'vm'
- })
- .otherwise({
- redirectTo: '/resetpassword'
- });
- }]);
- (function() {
- angular
- .module('myApp.resetpassword', ["ngMessages"])
- .directive('compareTo', function() {
- return {
- require: "ngModel",
- scope: {
- otherModelValue: "=compareTo"
- },
- link: function(scope, element, attributes, ngModel) {
- ngModel.$validators.compareTo = function(modelValue) {
- return modelValue == scope.otherModelValue;
- };
- scope.$watch("otherModelValue", function() {
- ngModel.$validate();
- });
- }
- };
- })
- .controller('ResetpasswordController', function($scope, $http, $location) {
- var vm = this;
- vm.message = "gg";
- vm.user = {
- username: "",
- password: "",
- confirmPassword: ""
- };
- vm.submit = function(isValid)
- {
- console.log("h");
- if (isValid)
- {
- vm.message = "Submitted " + vm.user.username;
- }
- else
- {
- vm.message = "There are still invalid fields below";
- }
- };
- });
- })();
- })();
- <div class="media-list">
- <h3>{{ vm.message }}</h3>
- <form name="registrationForm" novalidate ng-submit="vm.submit(registrationForm.$valid)">
- <div class="form-group">
- <label>User Name</label>
- <input type="text" name="username" class="form-control" ng-model="vm.user.username" required />
- <div ng-messages="registrationForm.username.$error" ng-messages-include="app/common/messages.html"></div>
- </div>
- <div class="form-group">
- <label>Password</label>
- <input type="password" name="password" class="form-control" ng-model="vm.user.password" required />
- <div ng-messages="registrationForm.password.$error" ng-messages-include="app/common/messages.html"></div>
- </div>
- <div class="form-group">
- <label>Confirm Password</label>
- <input type="password" name="confirmPassword" class="form-control"
- ng-model="vm.user.confirmPassword"
- required compare-to="vm.user.password" />
- <div ng-messages="registrationForm.confirmPassword.$error" ng-messages-include="app/common/messages.html"></div>
- </div>
- <div class="form-group">
- <button type="submit" ng-disabled="form.$invalid" class="btn btn-primary">Change Password</button>
- </div>
- </form>
- </div>
- <div class="messages">
- <div ng-message="required">Required</div>
- <div ng-message="minlength">Too short</div>
- <div ng-message="maxlength">Too long</div>
- <div ng-message="email">Invalid email address</div>
- <div ng-message="compareTo">Must match the previous entry</div>
- </div>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement