本文整理匯總了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');
}