我需要帮助来使用Complexify创建AngularJS
指令。这是一个密码表。我需要这个:
<input type="password" ng-model="password" />
<password-meter value="password" complexity="complexity"></passwordMeter>
<span class="label label-important" ng-show="complexity > 60">STRONG</span>
在我的例子中,当密码复杂度很高时,我<span>
的就是显示。
我的代码:
app.directive('passwordMeter', function() {
return {
restrict: 'E',
link: function link(scope, element, attrs) {
var minLengthPassword = 6;
var strengthScaleFactor = 1;
$(element).complexify({
minimumChars: minLengthPassword,
strengthScaleFactor: strengthScaleFactor
}, function(valid, complexity) {
if(valid) {
scope.complexity = complexity;
} else {
scope.complexity = 0;
}
});
scope.$watch('password', function() {
if(!scope.password) {
scope.complexity = 0;
}
});
}
};
});