wrap modifying model code by $apply()