html post 发送两次,angular 向后台发送数据,出现2次请求

因为要兼容IE7,没有用到route功能,在index.html页面include了菜单和登陆注册页面(header.html),在header页面中点击登陆时,后台接收到2次请求,一次无数据,第二次成功接收数据了。我检查页面了没有引用2次controller,但是不知为啥就是触发了2次请求。还请各位大神指点

html

购物车({{itemtotal}})

  • 时尚款BBBB手表{{item.name}}

    {{item.itemcount}}

    -

    +

    {{item.price * item.itemcount | number: 2}} 删除
  • 共({{itemtotal}})件商品{{total| number:2}}

    去购物车结算

  • 手机号码:

    请输入11位手机号码

    请输入正确的手机号码

  • 验证码:

    请输入正确验证码

    2-20个字符,可由中文、字母和数字组成

  • 密码:

    请输入密码

    2-20个字符,可由中文、字母和数字组成

  • 确认密码:

    两次输入的密码必须一致

    两次输入的密码必须一致

  • 阅读并同意入网服务协议服务条款、隐私政策

    请先同意协议

js代码:

function LoginCtrl($scope,$http,$rootScope) {

// console.log("请求进入")

// 二级导航显示

$(".telWatch").on("mouseenter",function(){

$(".secNav").slideDown(function(){

$(".secNav").stop(true);

})//.stop(true,true);

return;

})

$(".telWatch").on("mouseleave",function(){

$(".secNav").slideUp(function(){

$(".secNav").stop(true,true);

});

return;

})

//登陆事件

$scope.showLogin = function(){

//页面层

layer.open({

type: 1,

title:"登录",

shadeClose: true,

skin: 'layui-layer-rim', //加上边框

area: ['500px', '500px'], //宽高

content: $('.login')

})

}

//注册事件

$scope.showRegin = function(){

//页面层

layer.open({

type: 1,

title:"注册",

shadeClose: true,

skin: 'layui-layer-rim', //加上边框

area: ['500px', '500px'], //宽高

content:$('.reg')

})

}

//注册

$scope.addUsers = function (item) {

//表单正常提交

if($scope.userForm.$valid){

if($scope.user.pwd != $scope.user.pwd2){

$(".pwd2").show();

return false

}else{

$(".pwd2").hide();

}

var url = "http://10.12.12.74:30030/gateway.do";

//正常提交表单

$http({

method : 'POST',

url : url,

data: {phone:phone,password:pwd},

header:headers

}).success(function(data, status) {

console.log(data.msg);

// alert(item.pwd,item.pwd2)

// $(".layui-layer-close1").click();

// $('.user').show();

// $(".loginItem").hide();

}).error(function(data, status) {

});

}

else{

$scope.submitted = true;

}

};

$scope.rebpwd = true;

//登陆

$scope.userlogin = function (phone,pwd) {

console.log(phone);

//表单正常提交

if($scope.loginForm.$valid){

//正常提交表单

var url = "http://10.12.12.74:30030/gateway.do";

var headers= {'Content-Type':'application/json'};

$http({

method : 'POST',

url : url,

data: {phone:phone,password:pwd},

header:headers

}).success(function(data, status) {

console.log(data.msg);

}).error(function(data, status) {

console.log(data.msg);

});

}

else{

$scope.submitted = true;

}

};

$scope.logout = function(){

alert("退出按钮")

}

}

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值