Sunday, 4 June 2017

How do I compile AngularJS code on the server (NodeJS)?

I have an HTML file with AngularJS code in it. It's used by the front end and by the back end.

AngularJS on the front end takes the file, adds some variables (think: ), runs some logic (think: ng-if, ng-show, ng-for etc)...

The back end is a NodeJS server, and it needs the same file with the variables and logic already in place to do some operations with it (like exporting to PDF).

These operations can't be done on the front end, and I can't (shouldn't) send the front ends document to the back end (front end can be tampered with, also bandwidth usage).

I can make a different file for the server, where instead of AngularJS code I put the HTML in strings and do the logic using JavaScript, but this is not as elegant and maintainable.

How do I compile AngularJS code on the server?



via Ivan Rubinson

No comments:

Post a Comment