当前位置: 首页>>代码示例>>TypeScript>>正文


TypeScript CookieService.get方法代码示例

本文整理汇总了TypeScript中ngx-cookie.CookieService.get方法的典型用法代码示例。如果您正苦于以下问题:TypeScript CookieService.get方法的具体用法?TypeScript CookieService.get怎么用?TypeScript CookieService.get使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在ngx-cookie.CookieService的用法示例。


在下文中一共展示了CookieService.get方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的TypeScript代码示例。

示例1: init

    public init(config: i18nConfig = {}): void {
        let selectedLang: string = config.defaultLang ? config.defaultLang : DEFAULT_LANG;
        let supportedLangs: string[] = config.supportedLangs ? config.supportedLangs : DEFAULT_SUPPORTING_LANGS;

        this.translateService.addLangs(supportedLangs);
        this.translateService.setDefaultLang(selectedLang);

        if (config.enablei18Support) {
            //If user has selected lang, then directly use it
            let langSetting: string = this.cookie.get(config.langCookieKey ? config.langCookieKey : DEFAULT_LANG_COOKIE_KEY);
            if (!langSetting || langSetting.trim() === "") {
                //Use browser lang
                langSetting = this.translateService.getBrowserCultureLang().toLowerCase();
            }

            if (langSetting && langSetting.trim() !== "") {
                if (supportedLangs && supportedLangs.length > 0) {
                    if (supportedLangs.find(lang => lang === langSetting)) {
                        selectedLang = langSetting;
                    }
                }
            }
        }

        this.translateService.use(selectedLang);
    }
开发者ID:LilyFaFa,项目名称:harbor,代码行数:26,代码来源:translate-init.service.ts

示例2: getRequestOptionArgs

    getRequestOptionArgs(url: string, options?: RequestOptionsArgs) : RequestOptionsArgs {
        if (options == null) {
            options = new RequestOptions();
        }
        if (options.headers == null) {
            options.headers = new Headers();
        }

        options.headers.append('Content-Type', 'application/json');

        let prefix = url;
        if (prefix) {
            if (prefix.startsWith("http")) {
                prefix = prefix.split('/')[3];
            } else if (prefix.charAt(0) == '/') {
                prefix = prefix.substring(1).split('/')[0];
            }
        }

        let cookie = this.cookieService.get(prefix.toUpperCase().concat("-").concat('XSRF-TOKEN'));
        if (cookie) {
            options.headers.append('X-XSRF-TOKEN', cookie);
        }

        return options;
    }
开发者ID:pozitivity,项目名称:demo,代码行数:26,代码来源:custom-http.service.ts

示例3: intercept

  intercept(
    request: HttpRequest<any>,
    next: HttpHandler
  ): Observable<HttpEvent<any>> {
    if (!this.auth) {
      this.auth = this.injector.get(AuthService);
    }

    if (this.auth.isAuthenticated()) {
      request = request.clone({
        setHeaders: {
          'X-Auth-Token': this.auth.getToken()
        }
      });
    }

    // Add CSRF token for the Play CSRF filter
    const token = this.cookieService.get('PLAY_CSRF_TOKEN');
    if (token) {
      // Play looks for a token with the name Csrf-Token
      // https://www.playframework.com/documentation/2.4.x/ScalaCsrf
      request = request.clone({
        setHeaders: {
          'Csrf-Token': token
        }
      });
    }

    return next.handle(request);
  }
开发者ID:epot,项目名称:Gifter,代码行数:30,代码来源:token-interceptor.ts

示例4: constructor

    constructor(
        private translate: TranslateService,
        private cookie: CookieService,
        private session: SessionService,
        private appConfigService: AppConfigService,
        private titleService: Title) {

        translate.addLangs(supportedLangs);
        translate.setDefaultLang(enLang);

        //If user has selected lang, then directly use it
        let langSetting = this.cookie.get("harbor-lang");
        if (!langSetting || langSetting.trim() === "") {
            //Use browser lang
            langSetting = translate.getBrowserCultureLang().toLowerCase();
        }

        let selectedLang = this.isLangMatch(langSetting, supportedLangs) ? langSetting : enLang;
        translate.use(selectedLang);       

        //Override page title
        let key: string = "APP_TITLE.HARBOR";
        if (this.appConfigService.isIntegrationMode()) {
            key = "APP_TITLE.REG";
        }

        translate.get(key).subscribe((res: string) => {
            this.titleService.setTitle(res);
        });
    }
开发者ID:wknet123,项目名称:harbor,代码行数:30,代码来源:app.component.ts

示例5: isRegistered

 isRegistered() {
   let cookie = this.cookieService.get('COACH_REGISTER_FORM_SENT');
   console.log('Coach register form sent, ', cookie);
   if (cookie !== null && cookie !== undefined) {
     return true;
   }
 }
开发者ID:guillaumeLeRoy,项目名称:eritis_fe,代码行数:7,代码来源:register-coach-message.component.ts

示例6: hasAcceptedConditions

 hasAcceptedConditions() {
   let cookie = this.cookieService.get('COACH_REGISTER_CONDITIONS_ACCEPTED');
   console.log('Coach register conditions accepted, ', cookie);
   if (cookie !== null && cookie !== undefined) {
     return true;
   }
 }
开发者ID:guillaumeLeRoy,项目名称:eritis_fe,代码行数:7,代码来源:register-coach.component.ts

示例7: canActivate

    canActivate() {
        let sessionToken = this.cookieService.get('sessionToken');

        if (sessionToken === null || sessionToken === undefined) {
            this.stateService.setLoggedOut();
            // noinspection JSIgnoredPromiseFromCall
            this.router.navigateByUrl('not-logged-in');
        }
        return sessionToken != null;
    }
开发者ID:crispab,项目名称:codekvast,代码行数:10,代码来源:is-logged-in.guard.ts

示例8: ngOnInit

 ngOnInit() {
     const token = this.cookieService.get('social-authentication');
     if (token.length) {
         this.loginService.loginWithToken(token, false).then(() => {
                 this.cookieService.remove('social-authentication');
                 this.router.navigate(['']);
              }, () => {
                 this.router.navigate(['social-register'], {queryParams: {'success': 'false'}});
         });
     }
 }
开发者ID:bbranquinho,项目名称:chafraterno,代码行数:11,代码来源:social-auth.component.ts

示例9: defaultLanguage

    private defaultLanguage() {
        const isValid = (language: string) => LANGUAGES.indexOf(language) > -1;

        const persistedLanguage = this.cookieService.get(LANGUAGE_KEY);
        if (isValid(persistedLanguage)) {
            return persistedLanguage;
        }
        const browserLanguage = this.translateService.getBrowserLang();
        if (isValid(browserLanguage)) {
            return browserLanguage;
        }

        return LANGUAGES[0];
    }
开发者ID:alv-ch,项目名称:job-room,代码行数:14,代码来源:jobroom2-language.service.ts

示例10: requestIntercept

    requestIntercept(options?: RequestOptionsArgs): RequestOptionsArgs {
        const requestOptions = new RequestOptions(options);
        if (!options) {
            options = new BaseRequestOptions();
        }
        if (!requestOptions.params) {
            requestOptions.params = new URLSearchParams();
        }

        const translateLangKey = this.cookieService.get('NG_TRANSLATE_LANG_KEY');
        if (translateLangKey) {
            requestOptions.params.set('_ng', this.base64.encode(translateLangKey));
        }
        options.params = requestOptions.params;
        return options;
    }
开发者ID:alv-ch,项目名称:job-room,代码行数:16,代码来源:cache.interceptor.ts


注:本文中的ngx-cookie.CookieService.get方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。