I am trying to convert strings to AngularJS Service method calls in a controller. For example, I would like to convert the string "Contact.send(email)" to call an existing service method. I thought to use:
window["Contact"]["send"](email);
as in this thread - How to execute a JavaScript function when I have its name as a string - but it says that the Contact service is undefined, despite being injected into the controller.
eval("contact.send(email)");
? – Maverick Jul 18 '14 at 4:49Contact
onwindow
if it was injected into your controller? Post your controller and the service returningContact
please. – Chev Jul 18 '14 at 5:01