I have a problem with my HTML and AngularJS code. Initially, I defined the list in my controller which worked fine:
<li ng-repeat="a in idmasVesselstableList"><a>{{a.table_name}}</a></li>
And here is how I set up the controller:
angular
.module('myApp')
.controller('idmasCtrl', ['$scope', function($scope) {
$scope.idmasVesselstableList = [{"table_name":"api_574_structural_thickness"},{"table_name":"api_574_structural_thickness_rev_history"},{"table_name":"cml"},...];
}])
This displayed the list correctly. However, when I tried to define the list within an XMLHttpRequest, it did not work as expected. Here is the code snippet:
angular
.module('myApp')
.controller('idmasCtrl', ['$scope', function($scope) {
xmlhttp = new XMLHttpRequest();
xmlhttp.open("GET","/getvesselstablelist.js", true);
xmlhttp.onreadystatechange=function(){
if (xmlhttp.readyState==4 && xmlhttp.status==200){
string=xmlhttp.responseText;
$scope.idmasVesselstableList = JSON.parse(string);
}
}
xmlhttp.send();
}])
If anyone has any suggestions on how to generate the list correctly inside the XXMLHttpRequest on readystatechange, I would greatly appreciate it.
Thank you for your assistance.