# angular-jsdom-renderer

> Helps render angular pages on the server-side.

Latest version **0.5.0** (published 2014-12-20) · MIT license · 0 weekly downloads

> **Deprecated.** This package is deprecated.

## Install

```sh
npm install angular-jsdom-renderer
pnpm add angular-jsdom-renderer
yarn add angular-jsdom-renderer
bun add angular-jsdom-renderer
```

## Health

**Score 10/100 (F)** — status: deprecated.

Negative: deprecated.

## Facts

| | |
|---|---|
| Version | 0.5.0 |
| Published | 2014-12-20 |
| First published | 2014-07-09 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Node | >=0.10.0 |
| Dependencies | 1 |
| Known vulnerabilities | 0 |
| Install scripts | no |
| Author | https://github.com/pflannery |
| Maintainers | pflannery |
| Keywords | angular, static, render |

## Links

- npm: https://www.npmjs.com/package/angular-jsdom-renderer
- Repository: https://github.com/pflannery/angular-jsdom-renderer
- Homepage: https://github.com/angular-jsdom-renderer
- Issues: https://github.com/pflannery/angular-jsdom-renderer/issues
- npm.io page: https://npm.io/package/angular-jsdom-renderer

## Dependencies (1)

- [jsdom](https://npm.io/package/jsdom.md) ~1.5.0

## Recent versions

- 0.5.0 (latest) — 2014-12-20
- 0.4.5 — 2014-12-20
- 0.4.4 — 2014-12-20
- 0.4.3 — 2014-07-19
- 0.4.2 — 2014-07-19
- 0.4.0 — 2014-07-18
- 0.3.0 — 2014-07-17
- 0.2.0 — 2014-07-10
- 0.1.0 — 2014-07-10
- 0.0.1 — 2014-07-09

## README

# Angular JSDom Renderer

[![Build Status](https://secure.travis-ci.org/pflannery/angular-jsdom-renderer.png?branch=master)](http://travis-ci.org/pflannery/angular-jsdom-renderer "Check this project's build status on TravisCI")
[![NPM version](https://badge.fury.io/js/angular-jsdom-renderer.png)](https://npmjs.org/package/angular-jsdom-renderer "View this project on NPM")
[![Dependency Status](https://gemnasium.com/pflannery/angular-jsdom-renderer.png)](https://gemnasium.com/pflannery/angular-jsdom-renderer)
[![Gittip donate button](http://img.shields.io/gittip/pflannery.png)](https://www.gittip.com/pflannery/ "Donate weekly to this project using Gittip")
[![Analytics](https://ga-beacon.appspot.com/UA-47157500-1/angular-jsdom-renderer/readme)](https://github.com/pflannery/angular-jsdom-renderer)

Helps render angular pages on the server-side.

## Installation

    npm install angular-jsdom-renderer

## Usage

```javascript

// render using an interval poll selector
var renderer = require('angular-jsdom-renderer');

renderer.render({
	/* url to retrieve the html from */
	url: 'http://localhost:7559/',

	/* poll this selector until a match is found */
	pollSelector: 'body[data-content-loaded=true]',
	
	/* how often to poll the given selector. default 500 */
	pollSelectorMs: 100,
	
	/* how long to wait to give up polling selector. default 60000 */
	timeoutMs: 60000,
	
	/* complete callback. this = config */
	done: function(errors, window) {
		if (errors) {
			console.log(errors);
			return;
		}

        var document = window.document;
        var compiledHtml = document.outerHTML;
		// var angular = window.angular
		console.log(compiledHtml);

		// window will close after this callback
	}
});
```

```javascript
// render using a timeout only
var renderer = require('angular-jsdom-renderer');

renderer.render({
	/* url to retrieve the html from */
	url: 'http://localhost:7559/',
	
	/* how long to wait until rendering the content. default 5000 */
	timeoutMs: 5000,
	
	/* complete callback. this = config */
	done: function(errors, window) {
		if (errors) {
			console.log(errors);
			return;
		}
		
        var document = window.document;
        var compiledHtml = document.outerHTML;
		// var angular = window.angular
		console.log(compiledHtml);

		// window will close after this callback
	}
});

```

####Run the examples

- [Poll and display shared data](examples/share-data)
- [Using dynamic html and head scripts](examples/html-strings)

## API

```javascript

	/* renders the give url or file or html string */
	
	render({
		/* raw html. optional but must provide either url|file|html */
		html: '',
		/* raw file. optional but must provide either url|file|html  */
		file: config.file,
		/* raw url. optional but must provide either url|file|html  */
		url: '',
		/* injects script urls in to the html to be rendered */
		scripts: [],
		/* injects script statements in to the html to be rendered */
		src: [],
		/* see jsdom for more info - https://github.com/tmpvar/jsdom#how-it-works */
		features: config.features,
		/* see jsdom for more info - https://github.com/tmpvar/jsdom#doneerrors-window */
		done: function(jsdomErrors, window){},
		/* polls a selector until a match is found and then passes the rendered html to the config.done callback */
		pollSelector: 'body[data-content-loaded=true]'. default '',
		/* how often to poll the given selector. default 500 */
		pollSelectorMs: 500,
		/* how long to wait to give up polling selector. default 60000 */
		timeoutMs: 60000,
	});
	
```

## Contributing
Feel free to submit ideas and issues.

## License
Licensed under the incredibly [permissive](http://en.wikipedia.org/wiki/Permissive_free_software_licence) [MIT License](http://creativecommons.org/licenses/MIT/)
<br/>Copyright &copy; 2014+ Stringz Solutions Ltd
<br/>Copyright &copy; 2014+ [Peter Flannery](http://github.com/pflannery)

---
_Source: https://npm.io/package/angular-jsdom-renderer · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
