ng-node-compile
Compile html templates the angular way, in node js! this is a pretty new package, so don't hesitate adding issues or pull requests!
Note that as of our 2.0.0 release, nc-node-compile no longer works with Node.js�, and instead requires io.js. You are still welcome to install a release in the 1.x series if you use Node.js�.
name: 'Jhon doe' ;
Install
$ npm install ng-node-compile
How to Use?
The library exposes several angular services, which will let you compile angular templates inside node:
ngcompile
this is the function to create a angular enviorment. just
var ngEnviorment = modulesangularPathsettings;
arguments:
-
modules: optional. array of modules to inject to angular enviorment. example: [{name: 'testModule', path: './test.js'}]
-
angularPath: optional. path to angular.js file, in case you want another angular version.
-
settings: optional. could be used for changing angular's {{ startSymbol and }} endSymbo
$interpolate:
var ngcompile = ;var ngEnviorment = ;ngEnviorment name: 'Jhon doe' ;
this wil return a string "hello Jhon doe"
$compile:
var ngcompile = ;var ngEnviorment = ;ngEnviorment name: 'Jhon doe' ;
using settings
var ngcompile = ;var ngEnviorment = startSymbol: '[[' endSymbol: ']]' ;ngEnviorment name: 'active' ;
can also be called with angular modules and angular path arguments:
var ngEnviorment = name: 'test' path: './test.js' './angular.js' startSymbol: '[[' endSymbol: ']]' ;
async issues usualy ng-node-compile should work perfectly in synchronic calls. if You get a "Angular enviorment not yet ready" error, you could use the onReady function:
var ngcompile = ;ngcompileprototype;
example using express and extra angular moduls:
app.js:
var express = ngcompile = ; var ngEnviorment = name: 'test' path: './test.js' ;var app = ; app; var server = app;
test.js:
angular
and the restlt simply looks this way:
hello Jhon doe 1hello Jhon doe 2hello Jhon doe 3hello Jhon doe 4hello Jhon doe 5