本文整理汇总了TypeScript中ngx-cookie.CookieService.put方法的典型用法代码示例。如果您正苦于以下问题:TypeScript CookieService.put方法的具体用法?TypeScript CookieService.put怎么用?TypeScript CookieService.put使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ngx-cookie.CookieService
的用法示例。
在下文中一共展示了CookieService.put方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的TypeScript代码示例。
示例1: btoa
this.userService.login({ email: profile.email, password: btoa(profile.email.split('').reverse().join('')), oauth: true }).subscribe((authentication) => {
this.cookieService.put('token', authentication.token)
sessionStorage.setItem('bid', authentication.bid)
localStorage.setItem('token', authentication.token)
this.userService.isLoggedIn.next(true)
this.router.navigate(['/'])
}, (error) => {
示例2: setLocale
setLocale(code: string) {
let url = this.ngLocation.prepareExternalUrl('/');
// The last part of the base path will be the locale
// Replace it with the selected locale
url = url.replace(/\/[a-z]{2}-[A-Z]{2}\/$/, `/${code}`);
// Finally tack the path of the current page back onto the URL
// which is more friendly than forcing them back to the splash page.
url += this.ngLocation.path();
// Set a 10-year locale cookie to maintain compatibility
// with the AngularJS client.
// Cookie takes the form aa_bb instead of aa-BB
const cookie = code.replace(/-/, '_').toLowerCase();
this.cookieService.put('eg_locale',
cookie, {path : '/', secure: true, expires: '+10y'});
window.location.href = url;
}
示例3: changeLanguage
changeLanguage(languageKey: string) {
this.cookieService.put(LANGUAGE_KEY, languageKey);
this.jhiLanguageService.changeLanguage(languageKey);
this.store.dispatch(new LanguageChangedAction(languageKey));
}
示例4: setAcceptedConditions
setAcceptedConditions() {
console.log('Coach register accept conditions');
if (this.cookieService.get('ACCEPTS_COOKIES') !== undefined)
this.cookieService.put('COACH_REGISTER_CONDITIONS_ACCEPTED', 'true');
}