Can anyone please guide that how can I use JavaScript's "new Function()" constructor method in Angular 4/5' component.ts files. It gives error while building.
my-tmpl.component.ts:108:14: Invalid character.
'ngc' errored after 4.08 s
[15:05:16] Error: ngc compilation failed
My Example code in *.component.ts:
public clickEvent() {
var myString = "setTimeout(function() {alert('Time Out fired')}, 100); alert('Hello'); return false;";
new Function(myString)(); }
Your help would be appreciated.
Thanks, Jignesh