Changed to support angular 1.2+