angularJS的controller层向service层传参,并通过service层进行带参访问后台
angular.module('loginPage.service',[])
.factory('loginPageService',function(configService,$http){
return{
login : function(phone, callback){
var url = configService.getHostUrl() + '/loginPage/login.do?callback=JSON_CALLBACK'
$http.jsonp(url,{
method:'get',
params:{'phone':phone},
headers : {'Content-Type': 'application/x-www-form-urlencoded'},
})
.success(function(data){
var obj = JSON.stringify(data);
localStorage.setItem("userMessage",obj);
//console.log(localStorage.user);
callback(data);
})
}
}
})