I take that back, it would have be something more like:

    if ($scope.previousEnvironment === null || ($scope.previousEnvironment.toString() !== environment.toString())) {

    }