I want to do server side rendering with angularJS. Is it possible to do it in older version of angularJS(version before 2.0)?
1 Answers
There are a few npm modules which parse AngularJS templates server-side:
AngularJS-Server is built on jsdom, an implementation of the DOM API for Node, and angularcontext, which provides a lightweight container in which to instantiate your AngularJS application.
After I eventually got a very basic AngularJS example running on the server, I moved on to routing. The first problem I ran into was that jsdom just stubs out the Window object's XMLHttpRequest, so it doesn't do anything. Solution was pretty simple -- modify a line in lib/jsdom/browser/index.js:
XMLHttpRequest: require('../../../../xmlhttprequest').XMLHttpRequest
Your angular app must use html5mode. The reason behind this requirement is that browsers don't send the hashbang fragment to the server.
So for example, rendering on the server side http://domain.com/url#blah will just render http://domain.com/url.
The library exposes several angular services, which will let you compile angular templates inside node
References

- 1
- 1

- 24,148
- 7
- 127
- 265