小编aUX*_*der的帖子

ng-token-auth,ionic,devise_token_auth; 令牌在xhr请求中随机丢失

我继承了一个Ionic应用程序,该应用程序使用ng-token-auth+ devise_token_auth来处理身份验证以及正面和背面之间的会话.

发生的事情很奇怪.有时(特别是连接速度慢)请求(或响应)丢失,之后我只得到401http错误.

我知道,每当我发送请求时,令牌都会过期,但是当xhr请求被取消时(由我认为是服务器,或者是浏览器,我不知道),令牌已过期而未被新生成的令牌替换通过devise_token_auth宝石.

我知道Rails,但我不熟悉Angular,既不是Ionic,也不知道到底在哪里.

在阅读了很多SO答案之后,似乎没有人出现我的问题(在本地和分期/生产中发生),我检查了以下内容

  • storage被设为localStorage.
  • config.batch_request_buffer_throttle = 20.seconds
  • 取消的请求之间没有模式,有时我会为用户名执行get,有时会发布帖子或发表评论.
  • 不是CORS问题,因为它会永远或永远不会发生.(而且我正在使用离子博客中解释的代理)
  • 也许它可能与临时标题 chrome bug有关.但是,我怎么能确定?

令我感到困惑的是,它有时只会发生,而不是总是发生.(并且后端没有错误)

在devise_token_auth文档中找到的唯一解决方法是更改config.change_headers_on_each_requestfalse避免以这种方式重新生成令牌.

但我不喜欢这种解决方案,因为我认为它以不安全的方式隐藏真正的问题,而不是解决令牌丢失问题.有什么建议吗?

angularjs cordova ruby-on-rails-4 devise-token-auth

16
推荐指数
1
解决办法
337
查看次数

无法绑定到“ngForOf”,因为它不是 Ionic / Angular 9 中“ion-item”的已知属性

尝试使用电话号码填充简单的无线电组列表时

无法绑定到“ngForOf”,因为它不是“ion-item”的已知属性。

问题与 Angular 9 有关。可能的解决方案表明需要就位 BrowserModule 和 Common 模块。我想我明白了。然而,错误仍然存​​在。

在此输入图像描述

离子信息:

   Ionic CLI                     : 5.4.13 
   Ionic Framework               : @ionic/angular 5.1.0
   @angular-devkit/build-angular : 0.901.4
   @angular-devkit/schematics    : 9.1.4
   @angular/cli                  : 9.1.4
   @ionic/angular-toolkit        : 2.2.0

Capacitor:
   Capacitor CLI   : 2.0.2
   @capacitor/core : 2.0.2

Cordova:
   Cordova CLI       : 9.0.0 (cordova-lib@9.0.1)
   Cordova Platforms : android 8.1.0
   Cordova Plugins   : cordova-plugin-ionic-keyboard 2.2.0, cordova-plugin-ionic-webview 4.2.1, (and 6 other plugins)

Utility:
   cordova-res (update available: 0.15.0) : 0.6.0
   native-run (update available: 1.0.0)   : 0.2.8
Run Code Online (Sandbox Code Playgroud)

添加编号.page.ts

import { …
Run Code Online (Sandbox Code Playgroud)

ionic-framework ngfor angular ionic4

3
推荐指数
1
解决办法
3686
查看次数

ng 选择样式组标题和项目

我在我的 Angular 项目中使用 ng-select ( https://ng-select.github.io/ng-select#/data-sources ) 库来显示下拉列表,如下所示:

<ng-select
  [items]="flattenedSelectList"
  bindLabel="displayName"
  placeholder="Select specialty"
  notFoundText="No results found. Please try a different search criteria."
  bindValue="id"
  groupBy="type"
  [(ngModel)]="selectedSpecialtyId">
</ng-select>
Run Code Online (Sandbox Code Playgroud)

我想设置组标题以及每个组内的项目的样式?我该怎么做?

我在 .scss 文件中使用了以下内容,但它似乎没有应用更改。ng-optgroup 用于组标头,ng-option-label 用于项目。

.ng-optgroup {
  font-weight: bold;
  color: #dbe8ef;
}

.ng-option-label{
  color: red;
}
Run Code Online (Sandbox Code Playgroud)

angular-ngselect angular

3
推荐指数
1
解决办法
4645
查看次数

encodeURI(JSON.stringify())在URL中显示%255B

我试图通过Angular中的queryParam,它由这样的对象数组组成fooArray = [{foo: 'bar', foo: false}, {foo: 'bar', foo: false}]。在URL queryParam中,我收到以下消息:使用时,%255BencodeURI(JSON.stringify(this.fooArray))

我试过使用encodeURI(JSON.stringify())将数组编码为queryParam和JSON.parse(decodeURIComponent())以检索参数

fooArray = [{foo: 'bar', foo: false}, {foo: 'bar', foo: false}]

fooParam: encodeURI(JSON.stringify(this.fooArray))

JSON.parse(decodeURIComponent(params["fooParam"]))

javascript urlencode encodeuricomponent query-parameters

1
推荐指数
1
解决办法
115
查看次数