in general, logic should go inside a controller, directive, or run block. putting it in the global scope can cause issues with concatenation and minification and inclusion of other libraries.