发表于: 2017-05-02 22:11:11

1 1127


今天完成的事情:完成了任务10的上线功能。 
明天计划的事情:完成任务10
遇到的问题:总的来说挺坑的,刚开始post数据的时候 使用data.$.params({}),结果返回数据不能为空。

后来只好使用params{}传递数据了。但是用这个传的话 url链接会暴露上传的数据吧?

代码复用度不高,未能进行合理的优化。
收获:收获了以下代码。应该可以改成factory函数,直接在里面传参。这样就能复用了。

以前也用过sevice 感觉没fatcory好用啊。service要在里面把get到数据以后的逻辑写死。factory的话 就能自己在controller里面加自己的逻辑。

$scope.shangxian=function(){

$http({

method:'post',

url:'/carrots-admin-ajax/a/u/article',

headers:{'Content-Type': undefined},

params:{

title:$scope.title,

type:$scope.type,

status:1,

img:$scope.imgUrl,

url:$scope.link,

industry:$scope.industry,

content:$scope.shuoming

},

}).then(function successCallback(response){

if (response.data.message=="success"){

alert("上线成功!")

}else{

alert("发生错误")

}

})

}



返回列表 返回列表
评论

    分享到