add makePinInput

This commit is contained in:
Matias Alejo Garcia 2014-12-03 13:44:55 -03:00 committed by Gustavo Maximiliano Cortez
commit 3627671307
3 changed files with 46 additions and 64 deletions

View file

@ -48,5 +48,24 @@ angular.module('copayApp.services')
ls.removeItem(KEY, cb);
};
root.makePinInput = function(scope, name, cb) {
Object.defineProperty(scope, name, {
get: function() {
return this['_' + name];
},
set: function(newValue) {
this['_' + name] = newValue;
scope.error = null;
if (newValue && newValue.length == 4) {
return cb(newValue);
}
},
enumerable: true,
configurable: true
});
};
return root;
});