window.Utils = $safeApply: (fn) -> phase = this.$root.$$phase; if(phase == '$apply' || phase == '$digest') fn() if(fn && (typeof(fn) == 'function')) else this.$apply(fn) removeFromArray: (value, array) -> index = array.indexOf(value) array.splice(index, 1)