本文整理汇总了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);
}
示例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;
}
示例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);
}
示例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);
});
}
示例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;
}
}
示例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;
}
}
示例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;
}
示例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'}});
});
}
}
示例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];
}
示例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;
}