I have the following constant in my AngularJS app and want to access its values using the function shown below. Problem is that I pass the key as string but obviously as shown in the code below it returns undefined, so I was wondering is there a way I can convert the string passed to constant key in order to return the correct constant value corresponding to the key being passed? Thanks
myApp.constant('clients', {
clientData: "clientDetails",
clientList: "clients" });
getConstV : function(Key){
//this one returns clientDetails
console.log(clients.clientData);
//This one FAIL...returns undefined
console.log(clients.Key);
}
How I call getConstE is as follows:
getConstV('clientDetails');