There is a more elegant way to do this if you leverage complex math. Basically, with a complex number you can represent a spot on the compass.

If you want to "average" or "smooth" two compass readings, you can do that in the complex domain and then convert back to the angle domain.
With this, we can use the math js library and leave your function basically in the same form that you had:
var smoothing = .9;
function lowPass(degree, oldVal) {
// var oldVal = $scope.compassBearing || 0;
var complexOldVal = math.complex({r:1, phi:oldVal * (math.pi/180)});
var complexNewVal = math.complex({r:1, phi:degree * (math.pi/180)});
var complexSmoothedValue = math.chain(complexNewVal)
.subtract(complexOldVal)
.multiply(smoothing)
.add(complexOldVal)
.done();
var smoothedValue = math.arg(complexSmoothedValue) * (180/math.pi);
if (smoothedValue < 0) { return 360 + smoothedValue; }
return smoothedValue;
}
document.write(lowPass(20, 30)+'<br>');
// 20.99634415156203
document.write(lowPass(10, 350)+'<br>');
// 8.029256754215519
You can fiddle with it here: http://jsbin.com/zelokaqoju/edit?html,output