18.0.1 • Published 8 months ago

@auscope/angular2parse v18.0.1

Weekly downloads
-
License
MIT
Repository
github
Last release
8 months ago

angular2parse

Parse util for angular expressions: html string -> angular temaplte

install

npm install angular2parse

// app.module.ts
@NgModule({
  imports: [Angular2ParseModule, ...],
  // ...
})
class AppModule {}

usage

import { Parse } from 'angular2parse';

@Injectable()
class MyService {
  constructor(private parser: Parse) {}
  
  parseAngularString() {
    const expression = `{
	positions: track.positions,
	cornerType: getCornerType(),
	material: track.color,
	width : 200000.0 }`;

   const expressionEvalFn = this.parser.eval(expression)
  
   const context = {
      getCornerType: () => 'value',
      track: {
          positions: [1,2,3],
          color: 'red',
        }
      }
   };
    
   const result = expressionEvalFn(context);
   console.log(result);
   // {positions: [1,2,3], cornerType: 'value', material: 'red', width: 2000}
  
}
18.0.1

8 months ago

18.0.0

8 months ago

17.0.0

1 year ago

4.0.1

2 years ago

4.0.0

2 years ago

2.0.3

3 years ago

2.0.4

3 years ago

2.0.2

3 years ago

2.0.1

3 years ago

2.0.0

3 years ago