本文整理汇总了TypeScript中ng2-cookies.Cookie.get方法的典型用法代码示例。如果您正苦于以下问题:TypeScript Cookie.get方法的具体用法?TypeScript Cookie.get怎么用?TypeScript Cookie.get使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ng2-cookies.Cookie
的用法示例。
在下文中一共展示了Cookie.get方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的TypeScript代码示例。
示例1: canActivate
canActivate(route: ActivatedRouteSnapshot, state: RouterStateSnapshot) {
// 存储appToken到session
if (!Cookie.get(CommonConfig.AUTH_TOKEN)) {
this.router.navigate(['/user/login']);
return false;
} else {
return true;
}
}
示例2: createHeaders
private createHeaders(contentType: string): Headers {
let headers = new Headers({'Content-Type': contentType});
let token = localStorage.getItem('bhmc_token');
if (!token) {
token = sessionStorage.getItem('bhmc_token');
}
if (token) {
headers.append('Authorization', 'Token ' + token);
}
// This cookie is added to responses by Django
let csrf = Cookie.get('csrftoken');
if (csrf) {
headers.append('X-CSRFToken', csrf);
}
return headers;
}
示例3: getResource
getResource(resourceUrl) : Observable<Foo>{
var headers = new Headers({'Content-type': 'application/x-www-form-urlencoded; charset=utf-8', 'Authorization': 'Bearer '+Cookie.get('access_token')});
var options = new RequestOptions({ headers: headers });
return this._http.get(resourceUrl, options)
.map((res:Response) => res.json())
.catch((error:any) => Observable.throw(error.json().error || 'Server error'));
}
示例4: getUser
public static getUser() {
const data = Cookie.get(CommonConfig.AUTH_USER_INFO);
if (data.length > 0) {
return JSON.parse(data);
}
}
示例5: getUserName
public static getUserName() {
return Cookie.get(CommonConfig.AUTH_USER_NAME);
}
示例6: getBy
public static getBy(key: string) {
return Cookie.get(key);
}
示例7: get
/**
* 获取授权密钥
*/
public static get() {
return Cookie.get(CommonConfig.AUTH_TOKEN);
}