<div ng-show="!Enabled" class="form-group">
<label class="col-md-3 control-label"><strong>Password</strong></label>
<div class="col-md-6">
<input type="password" id="updatedata.password" name="updatedata.password" class="form-control input-sm requiredpop" ng-model="updatedata.password" placeholder="Password" required>
</div>
</div>
<div ng-show="!Enabled" class="form-group">
<label class="col-md-3 control-label"><strong>Repeat Password</strong></label>
<div class="col-md-6">
<input type="password" id="updatedata.newpassword" name="updatedata.newpassword" class="form-control passpop input-sm" ng-model="updatedata.newpassword" password-match="updatedata.password" placeholder="Password" required>
<p style="color:red" ng-show="!updateForm.updatedata.newpassword.$invalid">Password Does not match</p>
</div>
</div>
<div class="form-group">
<label class="col-md-3 control-label"><strong>Email</strong></label>
<div class="col-md-9">
<input type="email" ng-model="updatedata.Email" class="control-label requiredpop" placeholder="enter valid email address" required>
</div>
</div>
appDirectives.directive('passwordMatch', [function () {
return {
restrict: 'A',
scope: true,
require: 'ngModel',
link: function (scope, elem, attrs, control) {
var checker = function () {
//get the value of the first password
var e1 = scope.$eval(attrs.ngModel);
//get the value of the other password
var e2 = scope.$eval(attrs.passwordMatch);
return e1 == e2;
};
scope.$watch(checker, function (n) {
//set the form control to valid if both
//passwords are the same, else invalid
control.$setValidity("unique", n);
});
}
};
}]);
<p style="color:red" ng-show="!updateForm.updatedata.newpassword.$error.passwordMatch">Password Does not match</p>
Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.
Have a better answer? Share it in a comment.
From novice to tech pro — start learning today.
You would only need to use an object if you're dealing with child scopes and you need to assign your model to an object of the parent scope - which is actually a pretty common scenario, and.. should be avoided.
If a property name has a period in it (and it shouldn't), you can use bracket notation, like this:
updateForm["updatedata.new
glad you got it working :)