1

I am fairly new to nodejs, just been playing around with it for a while.

Now I would like to use angularjs $compile on server-side. In the end I would like to have an API which receives html and json and compiles it together using angulars syntax.

To go in a little more detail, this is what it looks like in angular: plunkr

$compile(element.contents())(scope);

As you can see the angular function $compile is used to fill a template from a textarea. I would like to use this $compile function on server-side as a webservice.

tl;dr;: I would like to use angularjs as a templating engine for express/nodejs on server-side.

I am having troubles integrating angular. Do you think this is a liable approach at all?

1 Answer 1

1

Nope, this is not liable, you are drastically over-thinking your architecture, just create your angular.js application, render it using a standard node.js template engine as jade or ejs. Then in your angular app connect to an api provided by node.js and express, and let angular do it's job and node.js its job.

Each tool is used for his main purpose, angular is used for single-page-application that are communicating with the server side using ($http, $resource, sockets etc...). Node.js is a scripting language mostly used for server side, api creation, other operations.

My advice keep the job simple, playful bu simple, you will sleep better at nights.

Sign up to request clarification or add additional context in comments.

3 Comments

Thanks @Alexandru-Olaru, but I want to use angularjs specifically for its templating engine. I have had a look at mustache, handlebars and others but in my opinion angularjs provides the easiest templating dialekt (especially for dates and lists)
I am a bit confused of what you want to do, but any way to render the angular firstly you need an template engine if you are using express, jade or ejs... Angular manipulates DOM, on serverside he does nothing, he uses browsers api not Node.js api... This are 2 different things different interfaces.
I tried to specify my question more, i found a few hints that maybe angular2 runs on node server-side.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.