I need to set up a watch on a variable in order to trigger a rest service call whenever its value changes and update the count.
Below is the code snippet I have:
function myController($scope, $http) {
$scope.abc = abcValueFromOutsideOfMyController;
$scope.getAbcCnt= function()
{
url2 = baseURL + '/count/' + $scope.abc;
$http.get(url2).success(function (data) {
$scope.abcCnt = data.trim();
});
};
$scope.$watch('abc',getAbcCnt);
}
However, an error is being thrown:
ReferenceError: getAbcCnt is not defined
As a beginner in AngularJS, please guide me if there's a basic concept I'm overlooking and whether what I'm trying to achieve is feasible.
The solution mentioned here didn't address my issue AngularJS : Basic $watch not working