Hi @InfinityX ,
additional to the info provided by @sdidier I want to add that there is no exact answer of this question and it relevance of possible solution depends on the particular case.
So, in some case the usage of JSON construct could be very helpful when you for example assignee some property of object so you can do this in the Json file and then interpret this file in you js code. To read a json file you can use some construct like this:
//Global Variables
var pjson ="mfg.json";
var jsonData;
gotJSON=function(data){
console.log("gotJSON:Working on DATA >>>>"+data);
console.warn(data);
try{jsonData=JSON.parse(data);} catch(ex){console.log('exception');console.warn(ex);}
$scope.view.wdg.JSONList.list=jsonData.Steps;
$scope.view.wdg.JSONList.label='Title';
$scope.view.wdg.JSONList.value=jsonData.Steps[0].Title;
}
doRead=function (jsonFile){
fetch(jsonFile)
.then(response=>response.text())
.then(data=>gotJSON(data))
}
$scope.Init=function() {
doRead('./app/resources/Uploaded/'+pjson);
}
/////
$scope.$on('$ionicView.afterEnter',function(){
$scope.Init();})
Depending on this what your json file implements then you can do different things -. for e.g. setting multiple property:
$scope.app.JsonTest= function(){
//store in a global variabe some json properties for testing
//
var b={"chuck":{"visible":false,"shader":""},"chuckHolder":{"visible":false,"opacity":"1"},"chipHolder":{"visible":false,"opacity":"1"},
"chipScrew":{"visible":false,"shader":""},"chipBolt":{"visible":false,"opacity":"1"},"estop":{"visible":false,"opacity":"1"},
"frontDecal":{"visible":false,"shader":""},"spindleDecal":{"visible":false,"opacity":"1"},"estopFront":{"visible":false,"opacity":"1"}
}
$scope.JsonTestList=b;
$scope.setMutipleProps($scope.JsonTestList);
}
//======= definition of set multiple props
$scope.setMutipleProps= function(obj){
Object.keys(obj).forEach(function (item){
for(var prop in obj[item])
{
console.log("obj["+item+"]["+prop+"]="+obj[item][prop] )
$scope.view.wdg[item][prop]=obj[item][prop]
console.log("==>$scope.view.wdg["+item+"]["+prop+"]="+obj[item][prop] ) }
})
};
This and a lot of other things - but as already mentioned above this depend on your application case but also on your imagination, creativity and last but not least on your javascript skills.