When passing user input to a controller function, I have encountered the issue that empty strings do not declare object properties.
<form>
<input type="text" ng-model="data.location" />
<input type="text" ng-model="data.radius" />
<button type="button" ng-click="getSearch(data)">Search</button>
</form>
$scope.getSearch = function(data) {
console.log(data);
//undefined
//...but what if I want {location:'', radius:''}
};
Is there a way to ensure that object properties are created even when passing empty strings on the fly?