Reputation: 2959
I work with AngularJs. I have a factory providing services about buildings.
I have a lot of buildings (around 50-60) with a lot properties and sub-properties related to them (around 15-20, more or less complex). Business requirements force me to store all the data about buildings in JS format.
So I created an object like that:
var Buildings = {
myFirstBuilding: {
id: 1,
name: 'Building 1',
quantity: 0,
costs: {
myFirstCost: {
name : 'Cost 1',
value: 10,
isAvailable: 0
},
mySecondCost: {
name : 'Cost 2',
value: 20,
isAvailable: 0
}
},
workersAvailable: 0,
type: 'Type 1',
/*
other properties...
*/,
mySecondBuilding: {
id: 1,
name: 'Building 2',
quantity: 3,
/*
and so on...
*/
I can update the structure of this object if needed. The only requirements is to be able to store it in user's browser and to "JSON it" when it's needed.
Where should I store this object in my project? Can I reference it from an external file in my factory? Should I include it directly in my factory?
Do you see any inconsistencies in this object as it's actually made in my example above?
Upvotes: 1
Views: 130
Reputation: 191976
You've got 3 options as far as I see it:
Upvotes: 4