I want to create a javascript function dynamically from Angular2. I am 
using the code below to generate the javascript function, it creates the 
function without the name. Instead I need this javascript function to be 
created along with function name which would be called by some other 
javascript object.

The angular2 code which I am using to create the javascript function

var startPos = value.indexOf("{");var endPos = value.lastIndexOf("}");var body 
= value.substring(startPos + 1, endPos);var args = "item";
value = new Function(args, body);return value;

The dynamic function which is created

(function(item/*``*/) {return $.ig.formatter(new Date(item["WEEK_END_DT"]), 
'date', "MM/dd/yyyy");})

Or

(function() {
return function myFunc(item){ function myFunc(item) {return $.ig.formatter(new 
Date(item["WEEK_END_DT"]), 'date', "MM/dd/yyyy");}}
})


Instead I need the dynamic function as below

function myFunc(item) {
    return $.ig.formatter(new Date(item["WEEK_END_DT"]), 'date', "MM/dd/yyyy");}

Note: myFunc function would be called by a third party control component 
i.e. IgniteUI - PivotGrid control. Currently I am getting the error message 
"myFunc is not defined". When I debugged the application, I could notice 
that the function is registered without a name as mentioned above.

-- 
You received this message because you are subscribed to the Google Groups 
"Angular and AngularJS discussion" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
Visit this group at https://groups.google.com/group/angular.
For more options, visit https://groups.google.com/d/optout.

Reply via email to