Hi,
Im building an offline sync for an Ionic 2 application.
When there is no internet connection i’ve to add it to the current JSON (Objects).
Under here example code and the console.log output what happens.
// Projects object
var oStreetById = this.getStreetHousesById(iProjectId, iStreetId, iHouseId);
// Nieuwe counter
var iCounter = Math.floor((Math.random()*6)+1);
// Data opbouwen voor de afbeeldingen met elementen
let oAddHouseObject = {
iCounter : {
'_id' : 'app-'+ iRandom,
'activities' : null,
'floor' : oHouseObject.object.floor,
'height' : '0',
'note' : oHouseObject.object.note,
'side' : oHouseObject.object.side,
'url' : oHouseObject.object.picture,
'width' : '0'
}
};
// Huis ophalen vanuit iHouseId
Object.assign(oStreetById, oAddHouseObject);
What happens in this piece of code is building an new Object to assign it to the main object so it will be visible for offline use.
But what really happens
0
:
{id: "590", width: "133", height: "200", side: "Voorzijde", …}
1
:
{id: "595", width: "133", height: "200", side: "Zijgevel", …}
iCounter
:
{_id: "app-504702", activities: null, floor: 4, height: "0", note: "", …}
iCounter has to been an random number, but iCounter is being readed as the key while it’s a variable at this place:
let oAddHouseObject = {
**iCounter** : {
'_id' : 'app-'+ iRandom,
'activities' : null,
'floor' : oHouseObject.object.floor,
'height' : '0',
'note' : oHouseObject.object.note,
'side' : oHouseObject.object.side,
'url' : oHouseObject.object.picture,
'width' : '0'
}
};
(Highlighted as iCounter)
Hope some one can help me out with this.
Thanks in advance