angularjs怎么从数据库获取数据

2025-04-06 09:36:43
推荐回答(1个)
回答1:

function ctrl($http,$scope){
var url = '../login/save.html',
transFn=function(obj) {
var str = [];
for(var p in obj){
str.push(encodeURIComponent(p) + "=" + encodeURIComponent(obj[p]));
}
return str.join("&").toString();
};

$scope.login = function(user){
var data=transFn(user);
$http.post(url+"?"+data).success(function(data, status, headers, config){
if (data.success){

}else{

}

}).error(function(data, status, headers, config){
alert("error");
});
};
}