jwadhams / json-logic-js

Build complex rules, serialize them as JSON, and execute them in JavaScript
MIT License
1.27k stars 139 forks source link

angular js 2 ionic support ? #37

Open tanzeelrana opened 7 years ago

tanzeelrana commented 7 years ago

has anyone been able to integrate this beauty with ionic or angular ? if so how ? thanks in advance !! Cheers

jwadhams commented 7 years ago

I'm using the living heck out of it with Angular 1. It's probably not terribly idiomatic, but most of the Angular interaction has something like this in the controller:

$scope.jsonLogic = jsonLogic;

Then in the views we can do things like

<li ng-repeat="(slug,subform) in deal.current_form.subforms" ng-show="jsonLogic.apply(subform.enabled, deal.data)">

(So here each subform has an "enabled" rule, that shows or hides the form based on data in "deal.data")