Angular Wait For Function To Finish