-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtest.js
More file actions
33 lines (32 loc) · 1.02 KB
/
test.js
File metadata and controls
33 lines (32 loc) · 1.02 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
var app = angular.module('app',[]);
app.directive('compare',function(){
return {
require: 'ngModel',
link: function(scope,ele,attrs,ctrl){
var flag = false;
scope.$watch("password",function(scope,ele,attrs,ctrl){
var password2 = attrs.myForm.password2.$viewValue;
if(scope != password2) {
flag = true;
}else{
flag = false;
}
attrs.myForm.password2.$invalid = flag;
})
scope.$watch("password2",function(scope,ele,attrs,ctrl){
var password = attrs.myForm.password.$viewValue;
if(scope != password) {
flag = true;
}else{
flag = false;
}
attrs.myForm.password2.$invalid = flag;
})
}
}
})
app.controller('formController',['$scope',function($scope){
$scope.submit = function(){
alert("提交成功");
}
}])