當前位置: 首頁>>代碼示例>>TypeScript>>正文


TypeScript CookieService.get方法代碼示例

本文整理匯總了TypeScript中angular2-cookie/core.CookieService.get方法的典型用法代碼示例。如果您正苦於以下問題:TypeScript CookieService.get方法的具體用法?TypeScript CookieService.get怎麽用?TypeScript CookieService.get使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在angular2-cookie/core.CookieService的用法示例。


在下文中一共展示了CookieService.get方法的10個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的TypeScript代碼示例。

示例1: baseHeaders

    public baseHeaders() {
        let headers: Headers = new Headers();

        if (this.cookies.get("csrftoken") == null) {
            this.http.get("/api/auth/csrf").subscribe();
        }
        headers.append("X-CSRFTOKEN", this.cookies.get("csrftoken"));
        return headers;
    }
開發者ID:BenjaminSchubert,項目名稱:HttpInfrastructure,代碼行數:9,代碼來源:headers.provider.ts

示例2: Observable

		this.user$ = new Observable(observer => {
				 this._userObserver = observer;

				var username = this._cookieService.get('username');
				var token = parseInt(this._cookieService.get('token'));

				if(username !== undefined && token !== undefined){
					this.setUserModel(username, token);
				}

		}).share();
開發者ID:KHAAAAN,項目名稱:ang2blog,代碼行數:11,代碼來源:user.service.ts

示例3: constructor

 constructor(private _cookieService: CookieService) {
     super();
     this.headers.set('Content-Type', 'application/json');
     this.headers.set('X-XSRF-TOKEN', this._cookieService.get('XSRF-TOKEN'));
     this.search = new URLSearchParams;
     this.url = 'http://localhost:3007';
 }
開發者ID:florinvoicuu,項目名稱:abc-frontend,代碼行數:7,代碼來源:extensions.ts

示例4: 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);
    }
開發者ID:dylan-mcdonald,項目名稱:nmpalate,代碼行數:30,代碼來源:question.ts

示例5: appendHeaders

	appendHeaders(headers: Headers){
		let auth_cookie = this.cookie.get('Token');
		if(auth_cookie){
			headers.append('Authorization', 'Token ' + auth_cookie);
		}
		return headers;
	}
開發者ID:nmarasigan16,項目名稱:ThetaTauAngularApp,代碼行數:7,代碼來源:url.service.ts

示例6: AuthOptions

 public AuthOptions(): RequestOptions {
     let token = this._cookieService.get('token');
     let args = new RequestOptions();
     args.withCredentials = true;
     let headers = new Headers({ 'Content-Type': 'application/json; charset=utf-8' });
     args.headers = headers;
     return args;
 }
開發者ID:cholewa1992,項目名稱:ReviewIT,代碼行數:8,代碼來源:apihelper.service.ts

示例7: ngOnInit

 ngOnInit() {
     let token = this.cookieService.get('social-authentication');
     if (token.length) {
         this.loginService.loginWithToken(token, false).then(() => {
                 this.cookieService.remove('social-authentication');
                 this.Auth.authorize(true);
              }, () => {
                 this.router.navigate(['social-register'], {queryParams: {'success': 'false'}});
         });
     }
 }
開發者ID:bonhamcm,項目名稱:generator-jhipster,代碼行數:11,代碼來源:_social-auth.component.ts

示例8: ngOnInit

 ngOnInit() {
     let token = this.cookieService.get('social-authentication')
     if (token.length) {
         this.loginService.loginWithToken(token, false).then(() => {
                 this.cookieService.remove('social-authentication');
                 this.Auth.authorize(true);
              }, () => {
                 this.$state.go('social-register', {'success': 'false'});
         });
     }
 }
開發者ID:lrkwz,項目名稱:generator-jhipster,代碼行數:11,代碼來源:_social-auth.component.ts

示例9: _isCookieValid

    private _isCookieValid(): Observable<boolean> {
        // Requires authentication
        var cookie: string = this._cookieService.get(COOKIE_KEY);

        // If either of the cookie is not available or the cookie expired, return false.
        if (!cookie) {
            return Observable.of(false);
        }

        return Observable.of(true);
    }
開發者ID:JeremyOT,項目名稱:xenon,代碼行數:11,代碼來源:authentication.service.ts

示例10: getScore

		getScore() {
			let score = this.cookieService.get("score");
			let parsedScore = score.split(",");
			let userScore = new TasteCoordinates(Number(parsedScore[0]), Number(parsedScore[1]), Number(parsedScore[2]));

			let currentBeer = undefined;
			let beerDistance = Number.POSITIVE_INFINITY;
			let newBeerDistance = Number.POSITIVE_INFINITY;
			this.beerList.forEach(function(beer) {
				newBeerDistance = userScore.euclideanDistance(beer.coordinates);
				if(newBeerDistance < beerDistance) {
					currentBeer = beer;
					beerDistance = newBeerDistance;
				}
			});
			this.selectedBeer = currentBeer;
			this.beerDescription = currentBeer.description;
			this.beerImageUrl = currentBeer.imageUrl;
			this.beerName = currentBeer.name;

			let currentChile = undefined;
			let chileDistance = Number.POSITIVE_INFINITY;
			let newChileDistance = Number.POSITIVE_INFINITY;
			this.chileList.forEach(function(chile) {
				newChileDistance = userScore.euclideanDistance(chile.coordinates);
				if(newChileDistance < chileDistance) {
					currentChile = chile;
					chileDistance = newChileDistance;
				}
			});
			this.selectedChile = currentChile;
			this.chileDescription = currentChile.description;
			this.chileImageUrl = currentChile.imageUrl;
			this.chileName = currentChile.name;

			let currentFood = undefined;
			let foodDistance = Number.POSITIVE_INFINITY;
			let newFoodDistance = Number.POSITIVE_INFINITY;
			this.foodList.forEach(function(food) {
				newFoodDistance = userScore.euclideanDistance(food.coordinates);
				if(newFoodDistance < foodDistance) {
					currentFood = food;
					foodDistance = newFoodDistance;
				}
			});
			this.selectedFood = currentFood;
			this.foodDescription = currentFood.description;
			this.foodImageUrl = currentFood.imageUrl;
			this.foodName = currentFood.name;
		}
開發者ID:dylan-mcdonald,項目名稱:nmpalate,代碼行數:50,代碼來源:result.ts


注:本文中的angular2-cookie/core.CookieService.get方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。