Fix for browserify

Browserify provides (I think) `module.exports` as the `this` argument to its modules. Therefore angular isn't available. This code falls back to use `window` if it can't find angular on the root.