Skip to content

Instantly share code, notes, and snippets.

@r-k-b
Last active August 29, 2015 14:02
Show Gist options
  • Save r-k-b/9778ae4e52be15d9ef21 to your computer and use it in GitHub Desktop.
Save r-k-b/9778ae4e52be15d9ef21 to your computer and use it in GitHub Desktop.
Quick demo of interacting with cookies on Adobe Business Catalyst
// Requires /CatalystScripts/Java_Cookies.js
(function(){
var cookieApp = angular.module('cookie-app', []);
cookieApp.$inject = ['$scope'];
cookieApp.controller('cookie-read-write', function($scope){
$scope.visitorDeviceClass = cookie('visitorDeviceClass');
$scope.customCookie = cookie('customCookie');
// Model(s) have changed, update the cookie
$scope.$watch('visitorDeviceClass', function(){
cookie('visitorDeviceClass', $scope.visitorDeviceClass, {
path: '/'
});
});
$scope.$watch('customCookie', function(){
cookie('customCookie', $scope.customCookie, {
path: '/'
});
})
});
})();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment