I am working with a JavaScript object that looks like this:
var Test = function () {
var x;
var y;
this.start = function() {
//some action
if ( x > y) {
x = x* 10; // update $scope.x in Angular
}
};
this.end = function() {
//other action
};
function anotherAction() {
};
};
In addition, I have an Angular controller:
testModule.controller('TestCtrl', function ($scope, $location) {
var test = new Test();
//$scope.x = value from test
}
I am trying to establish a connection between the Angular controller and the Test
entity. Specifically, I want to capture when test.end()
is called, retrieve the returned value, or pass the value from test.end()
to Angular. Is this possible?
Update:
The values of x and y can be updated in the test.start() method, and I need to pass the new value (x or y) to the Angular controller after updating them. I want to listen for changes in x or y, similar to how Angular listens for model changes.
How can I capture this event in Angular?
I apologize for the basic question.