首页 > Web开发 > 详细

angular js 多处获取ajax数据的方法

时间:2017-05-05 18:19:04      阅读:280      评论:0      收藏:0      [点我收藏+]
angular js 多处获取ajax数据的方法

var app=angular.module("cart",[]);
app.service("getData",function ($http) {
return{
ajax:function () {
return $http.get("product.json");
}
}
});

app.controller("listCtrl",function ($scope,getData) {
getData.ajax().then(function (res) {
$scope.data=res.data;
})
});
app.controller("detailCtrl",function ($scope,getData) {
getData.ajax().then(function (res) {
$scope.data=res.data;
})
});

angular js 多处获取ajax数据的方法

原文:http://www.cnblogs.com/yaomengli/p/6814119.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!