Skip to content

Commit a396f1a

Browse files
Added angular-cookie (https://github.com/ivpusic/angular-cookie) definitions
1 parent ab24621 commit a396f1a

File tree

2 files changed

+86
-0
lines changed

2 files changed

+86
-0
lines changed
+21
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
/// <reference path='../angularjs/angular.d.ts' />
2+
/// <reference path='angular-cookie.d.ts' />
3+
4+
angular.module('myApp', ['ipCookie'])
5+
.controller('cookieController', ['ipCookie', function(ipCookie: angular.cookie.CookieService) {
6+
ipCookie('key', 'value');
7+
ipCookie('key', { value: 'value'});
8+
ipCookie('key', [1, 2, 3]);
9+
10+
ipCookie('key', 'value', { expires: 21 });
11+
ipCookie('key', 'value', { encode: function (value) { return value; } });
12+
13+
ipCookie();
14+
ipCookie('key');
15+
ipCookie('key', undefined, {decode: function (value) { return value; }});
16+
17+
ipCookie.remove('key');
18+
ipCookie.remove('key', { path: '/some/path/' });
19+
20+
var obj: Object = '255';
21+
}]);

angular-cookie/angular-cookie.d.ts

+65
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,65 @@
1+
// Type definitions for angular-cookie v4.1.0
2+
// Project: https://github.com/ivpusic/angular-cookie
3+
// Definitions by: Borislav Zhivkov <https://github.com/borislavjivkov>
4+
// Definitions: https://github.com/borisyankov/DefinitelyTyped
5+
6+
declare module angular.cookie {
7+
interface CookieService {
8+
/**
9+
* Get all cookies
10+
*/
11+
(): any;
12+
13+
/**
14+
* Get a cookie with a specific key
15+
*/
16+
(key: string): any;
17+
18+
/**
19+
* Create a cookie
20+
*/
21+
(key: string, value: any, options?: CookieOptions): any;
22+
23+
/**
24+
* Remove a cookie
25+
*/
26+
remove(key: string, options?: CookieOptions): void;
27+
}
28+
29+
interface CookieOptions {
30+
/**
31+
* The domain tells the browser to which domain the cookie should be sent. If you don't specify it, it becomes the domain of the page that sets the cookie.
32+
*/
33+
domain?: string;
34+
35+
/**
36+
* The path gives you the chance to specify a directory where the cookie is active.
37+
*/
38+
path?: string;
39+
40+
/**
41+
* Each cookie has an expiry date after which it is trashed. If you don't specify the expiry date the cookie is trashed when you close the browser.
42+
*/
43+
expires?: number;
44+
45+
/**
46+
* Allows you to set the expiration time in hours, minutes, seconds, or `milliseconds. If this is not specified, any expiration time specified will default to days.
47+
*/
48+
expirationUnit?: string;
49+
50+
/**
51+
* The Secure attribute is meant to keep cookie communication limited to encrypted transmission, directing browsers to use cookies only via secure/encrypted connections.
52+
*/
53+
secure?: boolean;
54+
55+
/**
56+
* The method that will be used to encode the cookie value (should be passed when using Set).
57+
*/
58+
encode?: (value: any) => any;
59+
60+
/**
61+
* The method that will be used to decode extracted cookie values (should be passed when using Get).
62+
*/
63+
decode?: (value: any) => any;
64+
}
65+
}

0 commit comments

Comments
 (0)