Is there a way to combine multiple variables into one variable in order to streamline code usage? How can I set it up so that I can utilize $scope.bundle instead of using $scope.acc.city, $scope.acc.state, and $scope.acc.country individually? I'm looking for a global variable that consolidates multiple variables for easy access without the need to repeatedly declare them.
This is how I envision it:
$scope.bundle = [{$scope.acc.city, $scope.acc.state, $scope.acc.country}];
$scope.postcode = resp.content;
if ($scope.postcode.length > 0) {
$scope.bundle = $scope.postcode[0];
$scope.acc = $scope.bundle;
} else {
$scope.bundle = '';
$scope.acc = $scope.bundle;
}
Instead of this:
if ($scope.postcode.length > 0) {
var data = $scope.postcode[0];
$scope.acc.city = data.city;
$scope.acc.state = data.state;
$scope.acc.country = data.country;
} else {
$scope.acc.city = '';
$scope.acc.state = '';
$scope.acc.country = '';
}