Mortgage Calculator - Angular Sample
This sample builds off of the Basic sample, however, all of the data uses Angular data binding and is automatically mapped to the object for us. The results do not need to be mapped because Angular operates on the same underlying object as the rule engine and will automatically update the page after the engine updates the values.
The following is an AngularJS controller that demonstrates executing rules. For more details on this approach, a working sample is available on the InRule Support Site.
var app = angular.module('mortgage', []);
app.controller('mortgageController', ['$scope', '$timeout', function ($scope,
$timeout) {
$scope.applyRules = function () {
var session = inrule.createRuleSession(); session.createEntity('Mortgage', $scope.mortgage); session.applyRules(function(log){});
}
$scope.calculatePaymentSchedule = function () { var session = inrule.createRuleSession();
var mortgageEntity = session.createEntity('Mortgage', $scope.mortgage);
// Need to run Auto-Sequental rules first, then our explicit ruleset session.applyRules(function(log){
mortgageEntity.executeRuleSet("CalcPaymentSchedule", [], function(log)
{});
});
}
}]);
Comments
0 comments
Please sign in to leave a comment.