I'm aware of how to do this with a promise on an http request, but in this case, the data must be initialized from an inline script.
This controller is already defined in the header js:
var testModule = angular.module('myTestModule', []);
testModule.controller('testCtrl', function ($scope) {
$scope.data = [];
});
The following html loads, and for sake of argument, let's say it takes a very long time to finish the script part:
<div ng-app="myTestModule" ng-controller="testCtrl">
...
</div>
<script type="text/javascript">
setInitialData(['boo', 'far']);
</script>
If the inline script were loaded BEFORE the div with ng-app, I wouldn't be having an issue, but in this case it may load after the controller has been instantiated. I'm trying to avoid an extra http request, though it's convenient to utilize a promise with an angular service.
Does anyone have any ideas for how to construct the function setInitialData so that it applies the data to the controller/scope?