I've encountered an issue with loading a JSON file that is nearly 19,000 lines long. When minified to a single line, it's about 240k. I'm currently loading this JSON into my app via the index.html file as a global variable:
<script type="text/javascript" src="js/cdjson.js"></script>
var _countries = {
"country": {
"USA": {
"currency": {
"currencyCode":["USD"],
"currencyName":["United States Dollar"],
"currencySymbol":["$"]
},
"info": {
...
...
},
"phone" : {
...
},
"postal" : {
...
}
},
"CAN" : {
...
}
}
}
Within the controller, I am assigning it to a $scope variable like so:
$scope.countries = _countries.country ;
. However, the HTML DOM for that controller tries to access the $scope variable before the object is fully loaded, resulting in JS object errors such as Cannot read property 'country' of undefined
.
Is there a way to prevent the page from rendering until the $scope object is completely loaded? The $scope country object is used in a
<select ng-repeat="countries as country">