change apply to $location.replace() into setCC function and remove $apply()