It seems that I may not be following the "Angular Way" as I cannot find similar use cases in the documentation.
In my code, I have an input that takes comma-separated inputs and triggers a function through ng-submit within the weatherController:
$scope.submit = function() {
var rawZipString = this.text;
var strippedString = rawZipString.replace(/\s+/g, '');
var zipArray = strippedString.split(',');
for(i=0;i<zipArray.length;i++){
Weather.getWeatherForecast(zipArray[i])
.then(function(forecast){
$scope.temperatures.push(forecast);
})
}
/** Create weather objects */
for(i=0;i<$scope.temperatures.length;i++){
var tempForecast = new weatherConstructor(zipArray[i],$scope.temperatures[i]);
$scope.zipForecast.push(tempForecast);
}
/** Format as JSON */
$scope.DOMdata = angular.toJson($scope.zipForecast);
console.log($scope.DOMdata);
}
This is how weatherConstructor is defined:
function weatherConstructor(zip,temp){
this.zip = zip;
this.temp = temp;
}
I am unsure of how to render the constructed JSON object ($scope.DOMdata) in the view, which has the following structure:
<div ng-controller="weatherController">
<h4 ng-repeat="DOM in DOMdata">
{{DOM.zip}} now is {{DOM.temp}}
</h4>