2017-11-27 16 views
0

このコンポーネントに同意したcookieを実装しようとしていますhttps://github.com/tinesoft/ngx-cookieconsent。情報はサイトに表示されますが、同意しても更新後に再び表示されます。私はこの出来事を記入する必要がありますが、私はどのようにして分かりません。各サイトのCookie同意ポップアップ

import { Component, OnInit, OnDestroy } from '@angular/core'; 
import { NgcCookieConsentService } from 'ngx-cookieconsent'; 
import { Subscription } from 'rxjs/Subscription'; 

@Component({ 
    selector: 'app-root', 
    templateUrl: './app.component.html', 
    styleUrls: ['./app.component.scss'] 
}) 
export class AppComponent implements OnInit, OnDestroy { 

    //keep refs to subscriptions to be able to unsubscribe later 
    private popupOpenSubscription: Subscription; 
    private popupCloseSubscription: Subscription; 
    private initializeSubscription: Subscription; 
    private statusChangeSubscription: Subscription; 
    private revokeChoiceSubscription: Subscription; 

    constructor(private ccService: NgcCookieConsentService){} 

    ngOnInit() { 
    // subscribe to cookieconsent observables to react to main events 
    this.popupOpenSubscription = this.ccService.popupOpen$.subscribe(
    () => { 
     // you can use this.ccService.getConfig() to do stuff... 
     }); 

    this.popupCloseSubscription = this.ccService.popupClose$.subscribe(
    () => { 
     // you can use this.ccService.getConfig() to do stuff... 
     }); 

    this.initializeSubscription = this.ccService.initialize$.subscribe(
     (event: NgcInitializeEvent) => { 
     // you can use this.ccService.getConfig() to do stuff... 
     }); 

    this.statusChangeSubscription = this.ccService.statusChange$.subscribe(
     (event: NgcStatusChangeEvent) => { 
     // you can use this.ccService.getConfig() to do stuff... 
     }); 

    this.revokeChoiceSubscription = this.ccService.revokeChoice$.subscribe(
    () => { 
     // you can use this.ccService.getConfig() to do stuff... 
     }); 
    } 

    ngOnDestroy() { 
    // unsubscribe to cookieconsent observables to prevent memory leaks 
    this.popupOpenSubscription.unsubscribe(); 
    this.popupCloseSubscription.unsubscribe(); 
    this.initializeSubscription.unsubscribe(); 
    this.statusChangeSubscription.unsubscribe(); 
    this.revokeChoiceSubscription.unsubscribe(); 
    } 
} 

答えて

0

私はあなたが設定を指定していないインポートから見ることができます...

import { NgcCookieConsentService } from 'ngx-cookieconsent'; 

あなたはクッキーを困らせる止めるため、作業(および取得する設定に引っ張るとドメインを指定する必要があります

const cookieConfig: NgcCookieConsentConfig = { 
    cookie: { 
    domain: 'example.com' 
    }, 
    // ... 
:!あなたがドメインを指定する場所人)

import {NgcCookieConsentModule, NgcCookieConsentConfig} from 'ngx-cookieconsent'; 

です

はあなたがNgcCookieConsentModuleを取得する場所での設定、すなわち

NgcCookieConsentModule.forRoot(cookieConfig) 
を渡します
関連する問題