gpt4 book ai didi

javascript - 类型错误 : Failed to construct 'PasswordCredential' : 'id' must not be empty

转载 作者:行者123 更新时间:2023-11-30 11:36:18 24 4
gpt4 key购买 nike

我想在我的 Angular 应用中实现凭证管理 API

我的 login.html 看起来像这样

<div id="login-form" data-ng-form="loginForm" data-ng-controller="LoginFormController">
<div>
<input type="text" name="username" placeholder="username" data-ng-model="loginCredentials.username" id="uid" autocomplete="username">
<input type="password" name="password" placeholder="password" data-ng-model="loginCredentials.password" id="pwd" autocomplete="new-password">
</div>
<div>
<button id="loginButton" data-ng-click="login()">{{'label.button.login' | translate}}</button>
</div>
<div data-ng-show="authenticationFailed">
<p>{{authenticationErrorMessage | translate}}</p>
</div>
</div>

我有 LoginFormController 作为我的 Controller 。在函数内部,我像这样创建了一个名为 PasswordCredential 的新对象

            var form = angular.element('#login-form');
//console.log(form);
var cred = new PasswordCredential(form);
//store the credentials
navigator.credentials.store(cred)
.then(function(){

});

但我收到错误 PasswordCredential : id must not be empty

请帮忙

最佳答案

而不是做表单样式

var form = angular.element('#login-form');
var cred = new PasswordCredential(form);
//store the credentials
navigator.credentials.store(cred)
.then(function(){

});

传入 PasswordCredential 对象样式

var cred  = new PasswordCredential({
id: scope.loginCredentials.username,
password: scope.loginCredentials.password
});
//store the credentials
navigator.credentials.store(cred)
.then(function(){
console.log("Done Saving Creds");
});

这应该是为了保存您的凭据!

关于javascript - 类型错误 : Failed to construct 'PasswordCredential' : 'id' must not be empty,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/44290627/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com