{"id":21959805,"url":"https://github.com/exportarts/ngx-cookie-banner","last_synced_at":"2025-04-23T18:05:51.094Z","repository":{"id":41735370,"uuid":"233213122","full_name":"exportarts/ngx-cookie-banner","owner":"exportarts","description":"An unopinionated cookie banner for Angular","archived":false,"fork":false,"pushed_at":"2024-11-26T18:19:53.000Z","size":1190,"stargazers_count":6,"open_issues_count":44,"forks_count":2,"subscribers_count":1,"default_branch":"master","last_synced_at":"2024-11-26T19:25:16.748Z","etag":null,"topics":["angular","cookie-consent"],"latest_commit_sha":null,"homepage":"","language":"TypeScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/exportarts.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2020-01-11T10:20:41.000Z","updated_at":"2021-06-17T19:42:19.000Z","dependencies_parsed_at":"2023-02-07T07:48:02.362Z","dependency_job_id":"df9141f8-f094-413d-8d95-23c660a90b23","html_url":"https://github.com/exportarts/ngx-cookie-banner","commit_stats":null,"previous_names":[],"tags_count":5,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/exportarts%2Fngx-cookie-banner","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/exportarts%2Fngx-cookie-banner/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/exportarts%2Fngx-cookie-banner/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/exportarts%2Fngx-cookie-banner/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/exportarts","download_url":"https://codeload.github.com/exportarts/ngx-cookie-banner/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":227090152,"owners_count":17729636,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["angular","cookie-consent"],"created_at":"2024-11-29T09:33:04.351Z","updated_at":"2024-11-29T09:33:05.162Z","avatar_url":"https://github.com/exportarts.png","language":"TypeScript","readme":"# ngx-cookie-banner\n\n[![lerna](https://img.shields.io/badge/maintained%20with-lerna-cc00ff.svg)](https://lerna.js.org/)\n[![npm](https://img.shields.io/npm/v/ngx-cookie-banner.svg)](https://www.npmjs.com/package/ngx-cookie-banner)\n[![Build Status](https://travis-ci.com/exportarts/ngx-cookie-banner.svg?branch=master)](https://travis-ci.com/exportarts/ngx-cookie-banner)\n[![Quality Gate Status](https://sonarcloud.io/api/project_badges/measure?project=exportarts_ngx-cookie-banner\u0026metric=alert_status)](https://sonarcloud.io/dashboard?id=exportarts_ngx-cookie-banner)\n\n## Motivation\n\nThis lib is inspired by [angular2-cookie-law](https://github.com/andreasonny83/angular2-cookie-law)\nwhich [is discontinued](https://github.com/andreasonny83/angular2-cookie-law/issues/42#issuecomment-655597390). Therefore, I rewrote the main\nfunctionality and removed much of the opinionated styles and behaviour.\n\n## Getting Started\n\n**Install the dependency**\n\n`npm i --save-exact ngx-cookie-banner`\n\n**Import NgxCookieBannerModule**\n\n```ts\nimport { BrowserAnimationsModule } from '@angular/platform-browser/animations';\nimport { NgxCookieBannerModule } from 'ngx-cookie-banner';\n\n@NgModule({\n  declarations: [\n    AppComponent\n  ],\n  imports: [\n    BrowserModule,\n    BrowserAnimationsModule,\n    NgxCookieBannerModule.forRoot({\n      cookieName: 'ngx-cookie-banner-demo-app',\n    })\n  ],\n  providers: [],\n  bootstrap: [AppComponent]\n})\nexport class AppModule { }\n```\n\n**Use the component**\n\n```html\n\u003c!-- app.component.html --\u003e\n\n\u003cngx-cookie-banner #cookie\u003e\n    \u003cdiv class=\"banner-inner\"\u003e\n        \u003cspan\u003e\n            We use Cookies!\n            \u003ca role=\"button\" (click)=\"cookie.dismiss()\"\u003edismiss\u003c/a\u003e\n        \u003c/span\u003e\n    \u003c/div\u003e\n\u003c/ngx-cookie-banner\u003e\n```\n\n```css\n/* app.component.scss */\n\n.banner-inner {\n    background: red;\n}\n.banner-inner a {\n    font-weight: bold;\n    cursor: pointer;\n}\n```\n\n```ts\n/* app.component.ts */\n\n@Component({\n  selector: 'app-root',\n  templateUrl: './app.component.html',\n  styleUrls: ['./app.component.scss']\n})\nexport class AppComponent implements AfterViewInit, OnDestroy {\n  \n  @ViewChild('cookie', { static: true })\n  banner: NgxCookieBannerComponent;\n\n  private _cookieSub: Subscription;\n\n  // It is currently necessary to manually subscribe at this\n  // point to initialize the banner component.\n  ngAfterViewInit() {\n    this._cookieSub = this.banner.isSeen.subscribe();\n  }\n\n  ngOnDestroy() {\n    this._cookieSub.unsubscribe();\n  }\n\n}\n```\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fexportarts%2Fngx-cookie-banner","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fexportarts%2Fngx-cookie-banner","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fexportarts%2Fngx-cookie-banner/lists"}