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


TypeScript ngx-Webstorage.LocalStorageService類代碼示例

本文整理匯總了TypeScript中ngx-Webstorage.LocalStorageService的典型用法代碼示例。如果您正苦於以下問題:TypeScript LocalStorageService類的具體用法?TypeScript LocalStorageService怎麽用?TypeScript LocalStorageService使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


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

示例1: storeAuthenticationToken

 storeAuthenticationToken(jwt, rememberMe) {
     if (rememberMe) {
         this.$localStorage.store('authenticationToken', jwt);
     } else {
         this.$sessionStorage.store('authenticationToken', jwt);
     }
 }
開發者ID:Doha2012,項目名稱:tutorials,代碼行數:7,代碼來源:auth-jwt.service.ts

示例2: getDefaultClientId

 getDefaultClientId() {
     //        if (typeof this.user == 'undefined') {
     //            this.getUserDetails();
     //        }
     //        return this.auth.getPayload().data.default_client_id;
     return this.localstorage.retrieve('client_id');
 }
開發者ID:megamtech,項目名稱:angular-php-framework,代碼行數:7,代碼來源:authentication.service.ts

示例3: requestIntercept

    requestIntercept(options?: RequestOptionsArgs): RequestOptionsArgs {
        if (!options || !options.url || (/^http/.test(options.url) && !(SERVER_API_URL && options.url.startsWith(SERVER_API_URL)))) {
            return options;
        }

        const token = this.localStorage.retrieve('authenticationToken') || this.sessionStorage.retrieve('authenticationToken');
        if (!!token) {
            options.headers.append('Authorization', 'Bearer ' + token);
        }
        return options;
    }
開發者ID:lbuthman,項目名稱:tasks-spring-angular,代碼行數:11,代碼來源:auth.interceptor.ts

示例4: intercept

    intercept(request: HttpRequest<any>, next: HttpHandler): Observable<HttpEvent<any>> {
        if (!request || !request.url || (/^http/.test(request.url) && !(SERVER_API_URL && request.url.startsWith(SERVER_API_URL)))) {
            return next.handle(request);
        }

        const token = this.localStorage.retrieve('authenticationToken') || this.sessionStorage.retrieve('authenticationToken');
        if (!!token) {
            request = request.clone({
                setHeaders: {
                    Authorization: 'Bearer ' + token
                }
            });
        }
        return next.handle(request);
    }
開發者ID:EugeneGoroschenya,項目名稱:jhipster-sample-application,代碼行數:15,代碼來源:auth.interceptor.ts

示例5: if

      .map((response) => {
        // Extract version on header
        const cacheVersion: string = response.headers.get('dmp-servercacheversion');
        const responseJson: { [key: string]: string } = response.json();

        if (responseJson.status === 'success' && this.getLanguageVersion(language) === cacheVersion) {
          // If existed in cache go on
          return this.localStorage.retrieve(AppConstant.LOCAL_STORAGE_KEY.CACHE_LANGUAGE + language);
        } else if (typeof responseJson.status === 'string') {
          console.warn('⚠️ Response from translation provider is not success');
          console.warn('  response :', responseJson);
        }
        else {
          console.debug('  Got new translation object');
          this.setLanguageVersion(language, cacheVersion);
        }

        // return Language object
        return response.json();
      })
開發者ID:PoompisekK,項目名稱:myWork,代碼行數:20,代碼來源:uearn-translation.provider.ts

示例6: Observable

 return new Observable(observer => {
     this.$localStorage.clear('authenticationToken');
     this.$sessionStorage.clear('authenticationToken');
     observer.complete();
 });
開發者ID:Doha2012,項目名稱:tutorials,代碼行數:5,代碼來源:auth-jwt.service.ts

示例7: getToken

 getToken() {
     return this.$localStorage.retrieve('authenticationToken') || this.$sessionStorage.retrieve('authenticationToken');
 }
開發者ID:Doha2012,項目名稱:tutorials,代碼行數:3,代碼來源:auth-jwt.service.ts

示例8:

      .catch((error) => {
        console.warn('⚠️ Error while loading translation :', error);

        return Observable.of(this.localStorage.retrieve(AppConstant.LOCAL_STORAGE_KEY.CACHE_LANGUAGE + language));
      });
開發者ID:PoompisekK,項目名稱:myWork,代碼行數:5,代碼來源:uearn-translation.provider.ts

示例9:

 complete: () => {
     this.localstorage.clear('client_id');
     this.user = null;
     //                    UIService.notify('You have been logged out', 'info');
     //                    $state.go('login');
 }
開發者ID:megamtech,項目名稱:angular-php-framework,代碼行數:6,代碼來源:authentication.service.ts


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