I am trying to put a watch on a variable, so that if it's value changes I call the rest service and get updated count.
Here is how my code looks like
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);
}
But, I get following error
ReferenceError: getAbcCnt is not defined
I am new to AngularJS, let me know if there is some fundamental concept I am missing and above is not possible to do.
This answer didn't help me AngularJS : Basic $watch not working