In my Angular controller, I have a JavaScript function where I am trying to call an Angular function. However, I am encountering the error: $scope.Name is not a function, $scope.dates is not a function.
function validation() {
$scope.pageload = true;
$scope.Name();
$scope.dates();
}
$scope.Name = function () {
// do something
}
$scope.dates = function () {
// do something
}
Everything works fine inside the controller.
var MyController = function ($scope, service)
{
function validation() {
$scope.pageload = true;
$scope.Name();
$scope.dates();
}
$scope.Name = function () {
// do something
}
$scope.dates = function () {
// do something
}
});
working:
var MyController = function ($scope, service)
{
LoginHomeService.getHomeService(function (data) {
$rootScope.CT1SessionObj = data.CT1SessionObj;
validation();
}, function (response) {
alert(response.Message);
});
function validation() {
$scope.pageload = true;
$scope.Name();
$scope.dates();
}
$scope.Name = function () {
// do something
}
$scope.dates = function () {
// do something
});
Not working:
var MyController = function ($scope, service)
{
LoginHomeService.getHomeService(function (data) {
$rootScope.CT1SessionObj = data.CT1SessionObj;
validation();
function validation() {
$scope.pageload = true;
$scope.Name();
$scope.dates();
}
$scope.Name = function () {
// do something
}
$scope.dates = function () {
// do something
}
}, function (response) {
alert(response.Message);
});
});