I was wondering if there was a "correct" way to listen for cookie changes on Angular? It would be awesome if I could listen and change values in my models depending on their new values.
Thanks.
'use strict';
app.controller('MainCtrl', function ($scope, $log, $cookies, $timeout) {
$scope.$watch(function() { return $cookies.test; }, function(newValue) {
$log.log('Cookie string: ' + $cookies.test)
});
$cookies.test = 'first value';
$timeout(function () {
$cookies.test = 'second value';
}, 1000);
});
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With