// HTML視圖組範圍
<div class="error" ng-show="error && error !== 'timeout' && !reset">Login failed</div>
在js控制器文件我有一些邏輯,基本上做了POST Ajax請求,然後返回響應,如果登錄不成功我想要顯示上面的'錯誤'div。
// js文件
LoginService.prototype.signIn = function(email, password) {
var url = $rootScope.rootDomain + '/user/login/new-ui';
var extraParams = { callback: 'JSON_CALLBACK', email: email, password: password };
$http({
url : url,
method : 'POST',
data : $.param(extraParams),
headers : { 'Content-Type' : 'application/x-www-form-urlencoded' }
})
.then(function(data) {
$localStorage.$reset();
// get ajax response and if success is 0 then login failed, show a hidden div
if (data.data.success == 0) {
$rootScope.error = true;
return;
}
任何人都可以提出什麼是我的JavaScript /角文件中的錯誤?
你的網絡反應是什麼樣的? – cport1
html是在頭部分還是相對於路由? –