Skip to content

Commit 685dd4f

Browse files
committed
Cookie docs
1 parent ac5dbdc commit 685dd4f

File tree

17 files changed

+164
-10
lines changed

17 files changed

+164
-10
lines changed

@types/core/compile/attributes.d.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ export class Attributes {
1818
);
1919
$rootScope: import("../scope/scope.js").Scope;
2020
$animate: import("../../interface.ts").AnimateService;
21-
$exceptionHandler: import("../../services/exception/interface.ts").ErrorHandler;
21+
$exceptionHandler: import("../../interface.ts").ErrorHandler;
2222
$sce: any;
2323
$attr: {};
2424
/** @type {import("../../shared/noderef.js").NodeRef} */

@types/directive/model/model.d.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -141,7 +141,7 @@ export class NgModelController {
141141
$$element: Element;
142142
$$animate: import("../../interface.ts").AnimateService;
143143
$$parse: import("../../core/parse/interface.ts").ParseService;
144-
$$exceptionHandler: import("../../services/exception/interface.ts").ErrorHandler;
144+
$$exceptionHandler: import("../../interface.ts").ErrorHandler;
145145
$$hasNativeValidators: boolean;
146146
$$classCache: {};
147147
$$eventRemovers: Set<any>;

@types/interface.d.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,9 @@ export * from "./index.js";
1010
export * from "./angular.js";
1111
export * from "./core/di/internal-injector.js";
1212
export * from "./core/scope/scope.js";
13+
export * from "./services/cookie/cookie.js";
14+
export * from "./services/cookie/interface.ts";
15+
export * from "./services/exception/interface.ts";
1316
import { Attributes } from "./core/compile/attributes.js";
1417
import { Scope } from "./core/scope/scope.js";
1518
/**

@types/services/cookie/cookie.d.ts

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/**
2-
* Service provider that creates a {@link ng.CookieService $cookie} service.
2+
* Service provider that creates a {@link CookieService $cookie} service.
33
* @type {ng.ServiceProvider}
44
*/
55
export class CookieProvider {
@@ -10,7 +10,6 @@ export class CookieProvider {
1010
)[];
1111
}
1212
/**
13-
* $cookies service class
1413
*
1514
* Provides high-level APIs for interacting with browser cookies:
1615
* - Raw get/set/remove
Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
1+
---
2+
title: $cookieProvider
3+
description: >
4+
Configuration provider for `$cookie` service.
5+
---
6+
7+
### Description
8+
9+
Instance of [CookieProvider](../../../typedoc/classes/CookieProvider.html) for
10+
configuring the [$cookie](../../../docs/service/cookie) service.
11+
12+
It allows you to set global default options that will apply to all cookies
13+
created, updated, or removed using the `$cookie` service.
14+
15+
### Properties
16+
17+
---
18+
19+
#### $cookieProvider.defaults
20+
21+
The [defaults](../../../typedoc/classes/CookieProvider.html#defaults) property
22+
defines global cookie settings. These values are applied to the `$cookie`
23+
service at initialization, and every cookie created through `$cookie.put()` or
24+
`$cookie.putObject()` will automatically inherit these defaults, unless
25+
overridden per-cookie.
26+
27+
- **Type:** [CookieOptions](../../../typedoc/interfaces/CookieOptions.html)
28+
- **Default:** `{}`
29+
- | **Options:** | Property | Type | Description |
30+
| ------------ | -------- | ----------------------------------------------- | ----------- |
31+
| **path** | `string` | URL path the cookie belongs to. Defaults to the |
32+
33+
current path. Commonly set to `'/'` to make cookies accessible across the
34+
entire site. | | **domain** | `string` | The domain the cookie is visible to.
35+
Useful for subdomains (e.g., `.example.com`). | | **expires** | `Date` |
36+
Expiration date. If omitted, the cookie becomes a _session cookie_ (deleted on
37+
browser close). | | **secure** | `boolean` | If `true`, the cookie is only
38+
sent over HTTPS. | | **samesite** | `"Strict" \| "Lax" \| "None"` | Controls
39+
cross-site cookie behavior. Required when `secure: true` and cross-site use is
40+
intended. | | **httponly** | _Not supported._ | Browser JS cannot set
41+
`HttpOnly` cookies. This must be done on the server. |
42+
43+
- **Example:**
44+
```js
45+
angular.module('demo', []).config(($cookieProvider) => {
46+
$cookieProvider.defaults = {
47+
path: '/',
48+
secure: true,
49+
samesite: 'Lax',
50+
};
51+
});
52+
```
53+
54+
---
55+
56+
For service description, see [$cookie](../../../docs/service/cookie).
Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
---
2+
title: $cookie
3+
description: >
4+
Provides read/write access to browser's cookies
5+
---
6+
7+
### Description
8+
9+
The **`$cookie`** service offers a simple API for interacting with browser
10+
cookies in AngularTS applications. It allows you to:
11+
12+
- Read existing cookies
13+
- Write new cookies
14+
- Delete cookies
15+
- Store and retrieve JavaScript objects (via JSON serialization)
16+
- Automatically URI-encode and decode values
17+
18+
#### Example
19+
20+
```js
21+
angular.module('app').controller(
22+
'UserCtrl',
23+
/** @param {ng.CookieService} $cookie */
24+
function ($cookie) {
25+
// Write cookie
26+
$cookie.put('session_id', 'abc123');
27+
28+
// Read cookie
29+
const session = $cookie.get('session_id');
30+
31+
// Store object
32+
$cookie.putObject('profile', { name: 'Alice', admin: true });
33+
34+
// Read object
35+
const profile = $cookie.getObject('profile');
36+
37+
// Remove cookie
38+
$cookie.remove('session_id');
39+
},
40+
);
41+
```
42+
43+
Cookie behavior can be customized globally using
44+
[`$cookieProvider.defaults`](../../../docs/provider/cookieprovider/#cookieproviderdefaults).
45+
Cookies are limited to roughly 4 KB, including key and value, so void storing
46+
large objects; prefer identifiers or short tokens.
47+
48+
For detailed method description, see
49+
[CookieService](../../../typedoc/classes/CookieService.html)

docs/static/typedoc/assets/navigation.js

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

docs/static/typedoc/assets/search.js

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
<!DOCTYPE html><html class="default" lang="en" data-base="../"><head><meta charset="utf-8"/><meta http-equiv="x-ua-compatible" content="IE=edge"/><title>CookieProvider | AngularTS</title><meta name="description" content="Documentation for AngularTS"/><meta name="viewport" content="width=device-width, initial-scale=1"/><link rel="stylesheet" href="../assets/style.css"/><link rel="stylesheet" href="../assets/highlight.css"/><script defer src="../assets/main.js"></script><script async src="../assets/icons.js" id="tsd-icons-script"></script><script async src="../assets/search.js" id="tsd-search-script"></script><script async src="../assets/navigation.js" id="tsd-nav-script"></script><script async src="../assets/hierarchy.js" id="tsd-hierarchy-script"></script></head><body><script>document.documentElement.dataset.theme = localStorage.getItem("tsd-theme") || "os";document.body.style.display="none";setTimeout(() => window.app?app.showPage():document.body.style.removeProperty("display"),500)</script><header class="tsd-page-toolbar"><div class="tsd-toolbar-contents container"><a href="../index.html" class="title">AngularTS</a><div id="tsd-toolbar-links"></div><button id="tsd-search-trigger" class="tsd-widget" aria-label="Search"><svg width="16" height="16" viewBox="0 0 16 16" fill="none" aria-hidden="true"><use href="../assets/icons.svg#icon-search"></use></svg></button><dialog id="tsd-search" aria-label="Search"><input role="combobox" id="tsd-search-input" aria-controls="tsd-search-results" aria-autocomplete="list" aria-expanded="true" autocapitalize="off" autocomplete="off" placeholder="Search the docs" maxLength="100"/><ul role="listbox" id="tsd-search-results"></ul><div id="tsd-search-status" aria-live="polite" aria-atomic="true"><div>Preparing search index...</div></div></dialog><a href="#" class="tsd-widget menu" id="tsd-toolbar-menu-trigger" data-toggle="menu" aria-label="Menu"><svg width="16" height="16" viewBox="0 0 16 16" fill="none" aria-hidden="true"><use href="../assets/icons.svg#icon-menu"></use></svg></a></div></header><div class="container container-main"><div class="col-content"><div class="tsd-page-title"><ul class="tsd-breadcrumb" aria-label="Breadcrumb"><li><a href="" aria-current="page">CookieProvider</a></li></ul><h1>Class CookieProvider</h1></div><section class="tsd-panel tsd-comment"><div class="tsd-comment tsd-typography"><p>Service provider that creates a <a href="CookieService.html" class="tsd-kind-class">$cookie</a> service.</p>
2+
</div></section><section class="tsd-panel-group tsd-index-group"><section class="tsd-panel tsd-index-panel"><details class="tsd-index-content tsd-accordion" open><summary class="tsd-accordion-summary tsd-index-summary"><svg width="20" height="20" viewBox="0 0 24 24" fill="none" aria-hidden="true"><use href="../assets/icons.svg#icon-chevronDown"></use></svg><h5 class="tsd-index-heading uppercase">Index</h5></summary><div class="tsd-accordion-details"><section class="tsd-index-section"><h3 class="tsd-index-heading">Constructors</h3><div class="tsd-index-list"><a href="#constructor" class="tsd-index-link"><svg class="tsd-kind-icon" viewBox="0 0 24 24" aria-label="Constructor"><use href="../assets/icons.svg#icon-512"></use></svg><span>constructor</span></a>
3+
</div></section><section class="tsd-index-section"><h3 class="tsd-index-heading">Properties</h3><div class="tsd-index-list"><a href="#get" class="tsd-index-link"><svg class="tsd-kind-icon" viewBox="0 0 24 24" aria-label="Property"><use href="../assets/icons.svg#icon-1024"></use></svg><span>$get</span></a>
4+
<a href="#defaults" class="tsd-index-link"><svg class="tsd-kind-icon" viewBox="0 0 24 24" aria-label="Property"><use href="../assets/icons.svg#icon-1024"></use></svg><span>defaults</span></a>
5+
</div></section></div></details></section></section><details class="tsd-panel-group tsd-member-group tsd-accordion" open><summary class="tsd-accordion-summary" data-key="section-Constructors"><svg width="20" height="20" viewBox="0 0 24 24" fill="none" aria-hidden="true"><use href="../assets/icons.svg#icon-chevronDown"></use></svg><h2>Constructors</h2></summary><section><section class="tsd-panel tsd-member"><h3 class="tsd-anchor-link" id="constructor"><span>constructor</span><a href="#constructor" aria-label="Permalink" class="tsd-anchor-icon"><svg viewBox="0 0 24 24" aria-hidden="true"><use href="../assets/icons.svg#icon-anchor"></use></svg></a></h3><ul class="tsd-signatures"><li class=""><div class="tsd-signature tsd-anchor-link" id="constructorcookieprovider"><span class="tsd-signature-keyword">new</span> <span class="tsd-kind-constructor-signature">CookieProvider</span><span class="tsd-signature-symbol">()</span><span class="tsd-signature-symbol">:</span> <a href="" class="tsd-signature-type tsd-kind-class">CookieProvider</a><a href="#constructorcookieprovider" aria-label="Permalink" class="tsd-anchor-icon"><svg viewBox="0 0 24 24" aria-hidden="true"><use href="../assets/icons.svg#icon-anchor"></use></svg></a></div><div class="tsd-description"><h4 class="tsd-returns-title">Returns <a href="" class="tsd-signature-type tsd-kind-class">CookieProvider</a></h4></div></li></ul></section></section></details><details class="tsd-panel-group tsd-member-group tsd-accordion" open><summary class="tsd-accordion-summary" data-key="section-Properties"><svg width="20" height="20" viewBox="0 0 24 24" fill="none" aria-hidden="true"><use href="../assets/icons.svg#icon-chevronDown"></use></svg><h2>Properties</h2></summary><section><section class="tsd-panel tsd-member"><h3 class="tsd-anchor-link" id="get"><span>$get</span><a href="#get" aria-label="Permalink" class="tsd-anchor-icon"><svg viewBox="0 0 24 24" aria-hidden="true"><use href="../assets/icons.svg#icon-anchor"></use></svg></a></h3><div class="tsd-signature"><span class="tsd-kind-property">$get</span><span class="tsd-signature-symbol">:</span> (<span class="tsd-signature-type">string</span> <span class="tsd-signature-symbol">|</span> (<span class="tsd-signature-symbol">(</span><span class="tsd-kind-parameter">$exceptionHandler</span><span class="tsd-signature-symbol">:</span> <a href="../types/ErrorHandler.html" class="tsd-signature-type tsd-kind-type-alias">ErrorHandler</a><span class="tsd-signature-symbol">)</span> <span class="tsd-signature-symbol">=&gt;</span> <a href="CookieService.html" class="tsd-signature-type tsd-kind-class">CookieService</a>))<span class="tsd-signature-symbol">[]</span><span class="tsd-signature-symbol"> = ...</span></div></section><section class="tsd-panel tsd-member"><h3 class="tsd-anchor-link" id="defaults"><span>defaults</span><a href="#defaults" aria-label="Permalink" class="tsd-anchor-icon"><svg viewBox="0 0 24 24" aria-hidden="true"><use href="../assets/icons.svg#icon-anchor"></use></svg></a></h3><div class="tsd-signature"><span class="tsd-kind-property">defaults</span><span class="tsd-signature-symbol">:</span> <span class="tsd-signature-symbol">{}</span></div></section></section></details></div><div class="col-sidebar"><div class="page-menu"><div class="tsd-navigation settings"><details class="tsd-accordion"><summary class="tsd-accordion-summary"><svg width="20" height="20" viewBox="0 0 24 24" fill="none" aria-hidden="true"><use href="../assets/icons.svg#icon-chevronDown"></use></svg><h3>Settings</h3></summary><div class="tsd-accordion-details"><div class="tsd-filter-visibility"><span class="settings-label">Member Visibility</span><ul id="tsd-filter-options"><li class="tsd-filter-item"><label class="tsd-filter-input"><input type="checkbox" id="tsd-filter-protected" name="protected"/><svg width="32" height="32" viewBox="0 0 32 32" aria-hidden="true"><rect class="tsd-checkbox-background" width="30" height="30" x="1" y="1" rx="6" fill="none"></rect><path class="tsd-checkbox-checkmark" d="M8.35422 16.8214L13.2143 21.75L24.6458 10.25" stroke="none" stroke-width="3.5" stroke-linejoin="round" fill="none"></path></svg><span>Protected</span></label></li><li class="tsd-filter-item"><label class="tsd-filter-input"><input type="checkbox" id="tsd-filter-inherited" name="inherited" checked/><svg width="32" height="32" viewBox="0 0 32 32" aria-hidden="true"><rect class="tsd-checkbox-background" width="30" height="30" x="1" y="1" rx="6" fill="none"></rect><path class="tsd-checkbox-checkmark" d="M8.35422 16.8214L13.2143 21.75L24.6458 10.25" stroke="none" stroke-width="3.5" stroke-linejoin="round" fill="none"></path></svg><span>Inherited</span></label></li><li class="tsd-filter-item"><label class="tsd-filter-input"><input type="checkbox" id="tsd-filter-external" name="external"/><svg width="32" height="32" viewBox="0 0 32 32" aria-hidden="true"><rect class="tsd-checkbox-background" width="30" height="30" x="1" y="1" rx="6" fill="none"></rect><path class="tsd-checkbox-checkmark" d="M8.35422 16.8214L13.2143 21.75L24.6458 10.25" stroke="none" stroke-width="3.5" stroke-linejoin="round" fill="none"></path></svg><span>External</span></label></li></ul></div><div class="tsd-theme-toggle"><label class="settings-label" for="tsd-theme">Theme</label><select id="tsd-theme"><option value="os">OS</option><option value="light">Light</option><option value="dark">Dark</option></select></div></div></details></div><details open class="tsd-accordion tsd-page-navigation"><summary class="tsd-accordion-summary"><svg width="20" height="20" viewBox="0 0 24 24" fill="none" aria-hidden="true"><use href="../assets/icons.svg#icon-chevronDown"></use></svg><h3>On This Page</h3></summary><div class="tsd-accordion-details"><details open class="tsd-accordion tsd-page-navigation-section"><summary class="tsd-accordion-summary" data-key="section-Constructors"><svg width="20" height="20" viewBox="0 0 24 24" fill="none" aria-hidden="true"><use href="../assets/icons.svg#icon-chevronDown"></use></svg>Constructors</summary><div><a href="#constructor"><svg class="tsd-kind-icon" viewBox="0 0 24 24" aria-label="Constructor"><use href="../assets/icons.svg#icon-512"></use></svg><span>constructor</span></a></div></details><details open class="tsd-accordion tsd-page-navigation-section"><summary class="tsd-accordion-summary" data-key="section-Properties"><svg width="20" height="20" viewBox="0 0 24 24" fill="none" aria-hidden="true"><use href="../assets/icons.svg#icon-chevronDown"></use></svg>Properties</summary><div><a href="#get"><svg class="tsd-kind-icon" viewBox="0 0 24 24" aria-label="Property"><use href="../assets/icons.svg#icon-1024"></use></svg><span>$get</span></a><a href="#defaults"><svg class="tsd-kind-icon" viewBox="0 0 24 24" aria-label="Property"><use href="../assets/icons.svg#icon-1024"></use></svg><span>defaults</span></a></div></details></div></details></div><div class="site-menu"><nav class="tsd-navigation"><a href="../index.html">AngularTS</a><ul class="tsd-small-nested-navigation" id="tsd-nav-container"><li>Loading...</li></ul></nav></div></div></div><footer><p class="tsd-generator">Generated using <a href="https://typedoc.org/" target="_blank">TypeDoc</a></p></footer><div class="overlay"></div></body></html>

0 commit comments

Comments
 (0)