如果用户以错误的方式输入密码,我正在尝试显示一条消息。
当用户输入详细信息登录错误时,以下函数返回错误:
scope.emailLogin = function () {
AuthService.emailLogin(scope.credentials)
.then(function () {
// Redirect
AssessmentService.loadAssessmentCache();
state.go('app.tab.assessments');
},
function (err) {
console.error(JSON.stringify(err));
scope.validationError = true;
});
};
在 html 中,如果验证错误变为真,我试图通过执行 ng-show 来显示消息,如下所示:
<p ng-show="validationError">Incorrect email or password</p>
总结:我只想在功能作为错误返回时显示一条消息
这是控制台日志,记录的内容:
modules.js:870 {"data":"Incorrect email or password","status":500,"config":{"method":"PUT","transformRequest":[null],"transformResponse":[null],"auth":false,"handlers":[null],"url":"http://localhost:8080/api/authcallbacks/local","headers":{"x-client-type":"figr","Accept":"application/json, text/plain, */*","Content-Type":"application/json;charset=utf-8"},"data":{"email":"user1@test.co","password":"123123"}},"statusText":"Internal Server Error"}
在我看来
,这应该可以工作,您可能需要检查一下
<p ng-show="validationError">Incorrect email or password</p>
在适当的 ng 控制器范围内。
愚蠢地...是爱奥尼奥尼亚。我不得不做一个 Ionic 服务,我的代码工作正常......抱歉浪费你的时间伙计们