Ich möchte prüfen, ob ein Cookie mit $ interval existiert. Ich rufe $ interval beim Laden der Seite an. Dieser Aufruf gibt in regelmäßigen Abständen einen Fehler aus:
> TypeError: fn is not a function
> at callback (angular.js:12516)
> at Scope.$eval (angular.js:17444)
> at Scope.$digest (angular.js:17257)
> at Scope.$apply (angular.js:17552)
> at tick (angular.js:12506)
Ich verstehe wirklich nicht warum.
Hier ist mein Code:
angular.module("appModule")
.controller("loginController", ["$scope", "$http", "$window", "$document", "$interval", "$cookies",
function ($scope, $http, $window, $document, $interval, $cookies) {
var stopInterval;
$scope.CheckLoginCookie = function() {
if ($cookies.get("Login") != null) {
if (angular.isDefined(stopInterval)) {
$interval.cancel(stopInterval);
stopInterval = undefined;
}
$window.location.href = $scope.UrlNotes;
}
}
$scope.Repeat = function()
{
stopInterval = $interval($scope.CheckLoginCookie(), 1000);
}
}]);
-Code von $ document.ready aufgerufen wird:
$document.ready(function() {
$scope.Repeat();
})
'$ Intervall ($ scope.CheckLoginCookie, 1000);' – str
Was für ein Fehler :) Vielen Dank. Kannst du das als Antwort posten? – FrenkyB