0

That's the way I would like to get this done, for example, if you close a pop-up window for 2 days in a short time, for example, 1 or 2, it should not do it again until 190 days.

var app = angular.module('PopUpUsers', []);
app.controller('ViewPopUp', ['$scope', '$timeout', function ($scope, $timeout) {
    $timeout(function () {
        $scope.PopUpViewDiv = true;
    }, 12500);
    $scope.ClosePopUp = function () {
        $scope.PopUpViewDiv = false;
    };
}]);

What I think I have to overlook right now and here it is counter to how many times you have clicked on close area and remember it in some form of cookies.

The problem is just: How do I get done so that they can remember how many times popup has closed?

How can I get the click count

Create cookie with AngularJS

Update code:

var app = angular.module('PopUpUsers', []);
app.controller('ViewPopUp', ['$scope', '$timeout', '$cookies', function ($scope, $timeout, $cookies) {
    var cookieWObject = $cookies.getObject('test');
    var count = 3;


    if (cookieWObject == count) {
        $scope.PopUpViewDiv = false;
    } else {
        $timeout(function() {
                $scope.PopUpViewDiv = true;
        }, 12500);

        $scope.ClosePopUp = function () {
            $scope.PopUpViewDiv = false;
            $cookies.putObject("test", count);
        };
    }
}]);
Jesper
  • 1
  • 1
  • When you say "for 2 days" do you mean you only show the user this pop-up once a day? How are you tracking that? I'm not sure exactly what you're asking though: yes, if you want to do this with cookies you'll need to read and write cookies to e.g. either record when the last time the user closed the dialog, or if you close the dialog and look at that value and it's too close, then record the date at which you should start showing the dialog again, and modify your other code to read and respect that. 190 days seems a long time though: are you sure the user will still have your cookies by then? – Rup May 20 '18 at 23:01
  • I'm just thinking about the cookie pop-up that appears on most "Danish" websites today. It's a law that makes me need to make it so that if the user says "ok" then the first one will be shown in 190 days again. Does it make sense? @Rup – Jesper May 20 '18 at 23:08
  • i have update @Rup – Jesper May 21 '18 at 01:28

0 Answers0