Attempting to conditionally set a variable to handle the first click user case. The goal is to set the variable based on that condition. An attempt is made to instantiate a model which retrieves the variable, but on the first click, the model has not been instantiated, resulting in an error. The desired solution is to set the variable as follows:
var filterInstance = $scope.filterModel.getChecks() ? $scope.filterModel.getChecks() : {};
The goal is for filterInstance to check $scope.filterModel.getChecks(), and if it returns undefined, set it to an empty object. Otherwise, use $scope.filterModel.getChecks(). Any guidance on this issue would be much appreciated. Thank you!