我有一个离子应用程序,我正在测试检查指纹登录的能力。所有这些都有效,但是当我检查用户是否存储了登录凭据并取回解密的值时,我想显示一个允许用户启动指纹登录的按钮。
问题是,当我从 收集凭据时恢复成功时SecureStorage
,我设置了一个变量来显示按钮 ( $scope.canUseFingerprint
),该按钮使用ng-if
. 但是按钮永远不会出现,除非我再次在电子邮件输入中键入一个字符(输入中没有“更改”功能)。
我已经检查过,它显示该变量已设置为 true,但在该电子邮件输入中输入单个字符之前,该按钮不会显示。
有人可以看看吗?
这是我的看法:
<form name="loginForm" ng-submit="login(email, password)">
<label>Email</label>
<input type="text" ng-model="email" placeholder="typehere"></input>
<label>Password</label>
<input type="text" ng-model="password" placeholder="typehere"></input>
<button type="submit">Test Login</button>
<!--Below Button Won't Showup-->
<button type="button" ng-if="canUseFingerprint" ng-click="showFingerPrint()">Show Finger Print</button>
<button type="button" ng-click="testShowFingerPrint()">Test Show Button</button>
<button type="button" ng-click="clearKeys()">Clear All Keys</button>
</form>
这是我的控制器:
$ionicPlatform.ready(function(){
$scope.canUseFingerprint = false; //Initialized to false
var ss = new cordova.plugins.SecureStorage(
function () {
console.log('Success');
// $scope.allowFingerprintLogin = true;
setTimeout(function(){
checkForLoginCreds(); //Checks for login credentials
},3000)
},
function (error) {
$scope.canUseFingerprint = false;
addLockScreen();
console.log('Error ' + error);
},
'my_app');
var checkForLoginCreds = function(){
ss.get(
function (value) {
console.log('Success, got ' + value);
// This should activate the button, but does nothing. It DOES get set to true. Only after typing single character in input does the button show.
$scope.canUseFingerprint = true;
},
function (error) { console.log('Error ' + error); },
'loginInfo');
}
})