I have a complicated response from an http
request as shown below:
"rates": [
{
"non_refundable": false,
"no_of_rooms": 1,
"includes_wifi": false,
"includes_boarding": true,
"has_promotions": true,
"group_code": "xgirbylkwb6xtg",
"currency": "INR",
"cancellation_policy": {
"under_cancellation": false,
"details": [
{
"from": "2016-12-25T00:00:00",
"flat_fee": 20309.01,
"currency": "INR"
}
],
"cancel_by_date": "2016-12-24T00:00:00",
"amount_type": "value"
}
}
]
Rates length is between 6-20 inside another array with length of around 200. The "cancellation_policy"
shows up only if "non_refundable": false
.
How I can access "from": "2016-12-25T00:00:00"
and change the format with Moment JS and how I can access "flat_fee": 20309.01
?
I tried using angular.forEach
already but it defines only the value of last array .
I tried this already:
if ($scope.data[i].rates[j].non_refundable == false) {
for (var d = $scope.data[i].rates[j].cancellation_policy.details.length - 1; d >= 0; d--) {
But I had no success.
ps: The value should show on $mdDialog
You don't need to loop under details, just do it like this :
var startdate = $scope.data[i].rates[j].cancellation_policy.details[0].from;
var new_date = moment(startdate).format('MMMM Do YYYY, h:mm:ss a');
var other = $scope.data[i].rates[j].cancellation_policy.details[0].flat_fee;
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.