diff --git a/index.html b/index.html
index 5631834a3..3fef2b20b 100644
--- a/index.html
+++ b/index.html
@@ -209,7 +209,7 @@
Join a Wallet in Creation
@@ -300,7 +300,7 @@
Your Wallet Password(doesn't need to be shared) Required
+ ng-model="walletPassword" check-strength="passwordStrength" tooltip="Password strength: {{passwordStrength}}" tooltip-trigger="focus" required>
Wallet name Optional
diff --git a/js/directives.js b/js/directives.js
index 822fdae85..33fad2040 100644
--- a/js/directives.js
+++ b/js/directives.js
@@ -124,7 +124,7 @@ angular.module('copay.directives')
return {
replace: false,
restrict: 'EACM',
- scope: { model: '=checkStrength' },
+ require: 'ngModel',
link: function(scope, element, attrs) {
var _grep = function(elems, callback, invert) {
var callbackInverse,
@@ -146,6 +146,7 @@ angular.module('copay.directives')
};
var strength = {
+ messages: ['too weak', 'weak', 'weak', 'medium', 'strong'],
colors: ['#c0392b', '#e74c3c', '#d35400', '#f39c12', '#27ae60'],
mesureStrength: function (p) {
var _force = 0;
@@ -178,14 +179,15 @@ angular.module('copay.directives')
else if (s <= 40) { idx = 3; }
else { idx = 4; }
- return { idx: idx + 1, col: this.colors[idx] };
+ return { idx: idx + 1, col: this.colors[idx], message: this.messages[idx] };
}
};
-
- scope.$watch('model', function (newValue, oldValue) {
+
+ scope.$watch(attrs.ngModel, function (newValue, oldValue) {
if (newValue && newValue !== '') {
var c = strength.getColor(strength.mesureStrength(newValue));
- element.css({ 'border-color': c.col })
+ element.css({ 'border-color': c.col });
+ scope[attrs.checkStrength] = c.message;
}
});
}