changed angular compile to accept a function