[AngularJS] Re: How can we allow users to add custom logic to Angular form?

2020-04-01 Thread Sander Elias
Hi Paras, You can use the typescript compiler from within your code, and capture the results Regards Sander -- 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,

[AngularJS] Re: How can we allow users to add custom logic to Angular form?

2020-04-01 Thread Paras Saxena
One last question, i want them to write typescript code instead of js. Do you have any clue on how to covert ts to js. As they are going to upload the ts file through the same angular application, i want to compile the code and then save it as js. And yeah Thank you so much -- You received

[AngularJS] Re: How can we allow users to add custom logic to Angular form?

2020-03-31 Thread Sander Elias
Hi Paras, With current browsers supporting the `import()` it becomes even easier, and you don't need the eval anymore. Just provide the script from an API endpoint that sets the content-type to the correct mime-type. you can then use the default export as the entry point. something like:

[AngularJS] Re: How can we allow users to add custom logic to Angular form?

2020-03-31 Thread Paras Saxena
Okay, so if I convert it to Javascript, do i need to do Eval it at once? As it is not a single line of code, there will be a lot of methods that will be called at different point of times. Like there will be a FormInitialize method, that will be called as soon as the form is initialized,

[AngularJS] Re: How can we allow users to add custom logic to Angular form?

2020-03-31 Thread Sander Elias
Hi Paras, Yes, but typescript needs to be compiled, so you need to compile it before you can use it. Compile, save the result to a text field, and you can eval it into action whenever you need it. When you dave the className into a separate text field, you can instantiate it on request. Just

[AngularJS] Re: How can we allow users to add custom logic to Angular form?

2020-03-31 Thread Paras Saxena
Thanks Sander. Is there any way to call some external typescript class that is not part of our angular solution at runtime? I want to give the users ability to write their own class with few methods, that will be called when the form component loads. Thanks. -- You received this message

[AngularJS] Re: How can we allow users to add custom logic to Angular form?

2020-03-31 Thread Sander Elias
Hi Paras, There is no safe way to do this. This is only possible when the people using and creating the forms are trusted. (an intranet app inside a corporation might adhere to that). With that out of the way, you can actually store JS functions into text fields, and use eval to activate them