我有 2 个 json 文件,services.json 和 services_show.json。在页面加载时,我正在从 services.json 获取数据并且它工作正常。单击按钮时,我需要从 service_show.json 获取内容并附加到服务数组,但它不起作用。
var beautyApp = angular.module('findbeauty', []);
beautyApp.controller('beautycntrl',function($scope,$http){
$http.get('http://localhost/Find-Beauty/media/services.json').success(function(data) {
$scope.services=data.services;
$scope.services1=data.services1;
});
$scope.Add = function(){
$http.get('http://localhost/Find-Beauty/media/services_show.json').success(function(data) {
console.log(angular.toJson(data.services));
$scope.services.push(data.services);
});
};
$scope.ViewMore = function(){
});
服务.json
{
"services":[
{
"name": "Arun",
"gender": "Damen",
"duration": "1.5 Stunden",
"price": "€65,00",
"imagepath": "media/images/prfilepic1.png",
"percentage": "90%"
},
],
"services1":[
{
"name": "Schnitt & Föhnen",
"gender": "Damen",
"duration": "1.5 Stunden",
"price": "€65,00",
"imagepath": "media/images/profilepic4.png",
"percentage": "25%"
},
]
}
service_show.json
{
"services":[
{
"name": "Schnitt & Föhnen",
"gender": "Damen",
"duration": "1.5 Stunden",
"price": "€65,00",
"imagepath": "media/images/profilepic4.png",
"percentage": "5%"
},
],
"services1":[
{
"name": "Schnitt & Föhnen",
"gender": "Damen",
"duration": "1.5 Stunden",
"price": "€65,00",
"imagepath": "media/images/prfilepic1.png",
"percentage": "50%"
},
]
}
如何将 services_show.json 数据推送到 $scope.services ?有什么帮助吗?