我从我的服务器获取此测试数据,如JSON:
{
"0": {
"campaign_id": "1",
"title": "Nike Air 2015 campaign",
"description": null,
"path_to_logo": null,
"start_time": "09/11/2015 22:42:08",
"end_time": "09/03/2016 22:42:08",
"paused": "0",
"destinations": {
"0": {
"destination_id": "1",
"url": "www.nike.com/nike_air",
"description": "Nike air destination",
"connections": {
"0": {
"connection_id": "3",
"tag_id": "0",
"country": "Scotland",
"county": "Yorkshire",
"town": "East Ham",
"post_code": "SE1 1AA",
"custom": "bus stop",
"description": "Connection number 3"
}
}
},
"1": {
"destination_id": "2",
"url": "www.nike.com/nike_air/sub_campaign",
"description": "Nike air - free laces promotion destination",
"connections": {
"0": {
"connection_id": "2",
"tag_id": "0",
"country": "Engerland",
"county": "Devon",
"town": "East Ham",
"post_code": "SE1 1AA",
"custom": "bus stop",
"description": "Connection number 2"
},
"1": {
"connection_id": "4",
"tag_id": "0",
"country": "Engerland",
"county": "Yorkshire",
"town": "Felixswtowe",
"post_code": "RB3 9YR",
"custom": "police staticon",
"description": "Connection number 4"
},
"2": {
"connection_id": "6",
"tag_id": "0",
"country": "Scotland",
"county": "Essex",
"town": "York",
"post_code": "JD8 4LF",
"custom": "somewhere else",
"description": "Connection number 6"
},
"3": {
"connection_id": "9",
"tag_id": "0",
"country": "Scotland",
"county": "Cork",
"town": "York",
"post_code": "JD8 4LF",
"custom": "in the ladies' loo",
"description": "Connection number 9"
}
}
}
}
},
"1": {
"campaign_id": "2",
"title": "Nike football boots campaign",
"description": null,
"path_to_logo": null,
"start_time": "09/12/2015 22:42:08",
"end_time": "09/01/2016 22:42:08",
"paused": "0",
"destinations": {
"0": {
"destination_id": "3",
"url": "www.nike.com/nike_football_boots/",
"description": "Nike footie boots destination",
"connections": {}
},
"1": {
"destination_id": "4",
"url": "www.nike.com/nike_football_boots/sub_campaign",
"description": "Buy left boot, get right boot free destination",
"connections": {}
}
}
},
"2": {
"campaign_id": "3",
"title": "Nike general promotion campaign",
"description": null,
"path_to_logo": null,
"start_time": "09/12/2013 22:42:08",
"end_time": "09/08/2016 22:42:08",
"paused": "0",
"destinations": {
"0": {
"destination_id": "5",
"url": "www.nike.com/general_promotion",
"description": "Nike general promotion destination",
"connections": {}
},
"1": {
"destination_id": "6",
"url": "www.nike.com/general_promotion/discount_coupon",
"description": "20% off coupon destination",
"connections": {}
}
}
}
}
现在,我想在前面添加一个新的“广告系列” 。
关注this question,我试试
var date = new Date();
date.setHours(0,0,0,0);
var blankCampaignData = {'title': '', 'description': '', 'path_to_logo': '',
'start_time': date, 'end_time' : date, 'paused': false};
Array.prototype.unshift.call($scope.campaignData, blankCampaignData);
但是,之后我有一个包含blankCampaignData
的对象。
我如何实现我想要的目标?