0

I'd like to use the $parser module of Angular inside an open source library I'm maintaining. The library is a templating engine for .docx . I would like to benefit from the filtering functionality, and also the parser in general (+ operations, dot syntax)

What would be the best way to have access to the module. given that my library should work in NodeJS?

I can already specify a parser like this:

doc.parser=function(expression) {
    return {get:function(scope) {return scope[expression].toUpperCase() }
}

The parser first param is the expression you would like to parse (for example user.name), it returns an object with a get function that you can call, in the same philosophy as the $parser module. The parser I create for now is just a demo parser that shows that you can UPPERCASE all the values of the expression.

I'm seeking for a way to say: doc.parser=$parser(), or something like this, and that should work in NodeJS and in the browser.

I found that file: https://raw.githubusercontent.com/angular/angular.js/master/src/ng/parse.js that is responsible for the parsing, but it needs the $filter module, ...

1 Answer 1

2

You cannot use the $parse method out of the box from AngularJS

Consider using Angular expressions - it does exactly what you want. And it works on bot server and client side.

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

Comments

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.