本文整理匯總了TypeScript中angular2-cookie/core.CookieService.put方法的典型用法代碼示例。如果您正苦於以下問題:TypeScript CookieService.put方法的具體用法?TypeScript CookieService.put怎麽用?TypeScript CookieService.put使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類angular2-cookie/core.CookieService
的用法示例。
在下文中一共展示了CookieService.put方法的9個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的TypeScript代碼示例。
示例1: onSaveResponse
onSaveResponse(result: any, error: any) {
if (error != null) {
console.log(error);
return;
}
this.user = result;
this._cookieService.put("username", this.user.Username);
this._cookieService.put("password", this.user.Password);
}
示例2: loginResponse
loginResponse(result: any, error: any) {
if (error != null) {
console.log(error);
return;
}
console.log(JSON.stringify(result));
this.user = result;
this._cookieService.put("username", this.user.Username);
this._cookieService.put("password", this.user.Password);
console.log(this.user);
console.log(this.isUserRegistered());
}
示例3: calculateScore
calculateScore(score, axis) {
let netScore;
let savedScore = this.cookieService.get("score");
//set score to default if it does not exist, and calculate from there
if (!savedScore) {
savedScore = ("0.5,0.5,0.5");
}
let dividedScore = savedScore.split(",");
//cookie values are in alphabetical order; savory, spice, sweet
//if an unexpected axis name appears, the score will simply remain the same
if(axis === "savory") {
netScore = Number(dividedScore[0]) + score;
dividedScore[0] = this.checkScoreBoundary(netScore);
} else if (axis === "spice") {
netScore = Number(dividedScore[1]) + score;
dividedScore[1] = this.checkScoreBoundary(netScore);
} else if (axis === "sweet") {
netScore = Number(dividedScore[2]) + score;
dividedScore[2] = this.checkScoreBoundary(netScore);
}
let newScore = "";
dividedScore.forEach(function(entry, index) {
newScore = newScore + entry;
if(index != 2) {
newScore = newScore + ',';
}
});
this.cookieService.put("score", newScore);
}
示例4: gotoDashboard
gotoDashboard(result) {
if (result) {
this.cookieService.put('loginCookie', 'true');
this.router.navigateByUrl('/dashboard');
} else {
this.showError('Incorrect email and/or password.');
}
}
示例5: put
put(key, value) {
if (key !== this.cacheKeys.Card) {
try {
this._cookieService.put(key, value);
this._localStorage.set(key, value);
this.cache[key] = value;
} catch (e) {
console.error('cache error!', e);
}
}
};
示例6: saveToken
public saveToken(value: Token) {
console.log('Token wird gespeichert: ' + JSON.stringify(value));
this._cookieService.put(this.tokenstorekey, JSON.stringify(value));
this._navibarService.hasToken(true);
}
示例7: initializeCookie
initializeCookie() {
//cookie values are in alphabetical order: savory, spicy, sweet
this.cookieService.put("score", "0.5,0.5,0.5");
}
示例8: logout
logout(): void {
this.user = this.initUser();
this._cookieService.put("username", null);
this._cookieService.put("password", null);
}
示例9: put
private put(key:ConfigKeys, valor:string) {
this._cookieService.put(ConfigKeys[key], valor, {expires: TEN_YEARS_FROM_NOW});
}