angularjs post data

zyip發表於2015-03-23

 

//post json 時收不到資料,目前只找到方法post form形式的key-value值

//關鍵是設定  headers: { 'Content-Type': 'application/x-www-form-urlencoded' }和data:'login=zyip@qq.com'

app.factory('googleBusiness', ['$window','$http', function(win,$http) {
    var document=win.document;
    return {
        getGoogleUserName:function(url,loginUser,successCallBack){
            var toUrl='/googlecfg/GetGoogleAccountByLoginName/';
            toUrl='http://localhost:7683/home/index';
            $http({
                url:toUrl,
                method: "POST",
                    headers: { 'Content-Type': 'application/x-www-form-urlencoded' }
                ,data:'login=zyip@qq.com'
            }).success(successCallBack);
        },
        saveGoogleUserName:function(loginUser,googleUserName){

        }
    };

}]);

 

相關文章