benmarch / spel2js

Parse Spring Expression Language in JavaScript
Other
69 stars 19 forks source link

class method cannot be evaluated #9

Closed harryburak closed 4 years ago

harryburak commented 4 years ago

Hi,

I have a custom class that is existed some variables. I wrote a method that takes a variable inside it and want to evaluate with spel2js. But, I take an error as shown below

"TypeError: Cannot read property 'activeContext' of undefined"

I also share symbolic codes below.

//Class export class Clazz{ //variables //method public foo(variable:string) : string{ //business Logic } }

const spelContext = StandardContext.create(); const compiledExpression = SpelExpressionEvaluator.compile("#foo('123') == '123'"); let result = compiledExpression.eval(spelContext, this.clazz);

benmarch commented 4 years ago

Hey @harryburak, thanks for bringing this to my attention. It looks like functions weren't implemented correctly at all. I fixed it in PR #8, and I'll release a new version in the next 24 hours.

benmarch commented 4 years ago

@harryburak, this is fixed in 0.2.7.

harryburak commented 4 years ago

Thank you @benmarch . It solved my problem. Take care...