I am trying to bind a promise to a view. I don\'t know if you can do that directly, but that\'s what I\'m attempting to do. Any ideas what I am doing wrong?
Note:
returning a reference to the scope variable holding the list should suffice.
function addressValidationController($scope,$timeout) {
var regions = {
US: [{code: 'WI',name: 'Wisconsin'}, {code: 'MN',name: 'Minnesota'}],
CA: [{code: 'ON',name: 'Ontario'}]
};
$scope._regions = [];
$scope.getRegions = function () {
$timeout(function () {
var countryRegions = regions[$scope.countryCode];
console.log(countryRegions);
if(countryRegions === undefined) {
$scope._regions = []
} else {
$scope._regions = countryRegions
}
}, 1000);
return $scope._regions;
};
}