use $apply+function