0

I'm looking for a good way to preform a calculation on a couple of inputs and store the total value in a $scope variable as well as a total field (disable).

Here is a jsfiddle - http://jsfiddle.net/U3pVM/18830/

In this case we need to apply unique visit / mobile visit = total visit, store the total in metricData.totalVisit, and set the value of the disabled field to that as well.

Thanks in advance!

1 Answer 1

2

Angular provides $watch to do stuff like this. You can simply do something like:

$scope.$watch('metricData', function(metricData) {
    metricData.totalVisit = metricData.uniqueVisit / metricData.mobileVisit;
}, true);

Fiddle: http://jsfiddle.net/j0ajrtzr/

(note this is just an example to demo basic functionality, more info at $scope.$watch)

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.