Q:

Simplifying Javascript if statement undefined

if (typeof $scope.input.gps === 'undefined') {
    $scope.msgBody  = 'Location not found.';
} else {
    $scope.msgBody  = $scope.input.gps+' not found.';
}
flash.pop({title: 'Error', body: $scope.msgBody, type: 'error'});

Would there be an easier way to do this if statement and include it inside the flash.pop

A:

There's nothing wrong with clear, easily maintained code even if it's a few characters more to type initially, it might save a lot of time and effort later.
Seems you need to set the value of $scope.msgBody, I don't think it's a good idea to do that in the assignment. Consider:
$scope.msgBody = typeof $scope.input.gps === 'undefined'? 'Location not found.' :
                                                          $scope.input.gps + ' not found.'

However, I don't think that's "easier".

A:

You may use $scope.msgBody = ($scope.input.gps || 'Location') + ' not found.';.
But note that Location will be used not only if $scope.input.gps is undefined, but also if null, "", 0, NaN and false. Those values are covered by the falsy concept, see http://www.sitepoint.com/javascript-truthy-falsy/.

