我刚刚将我在RC5上构建的应用程序升级到最终版本,而且我对我现在应该声明指令和管道的方式感到困惑.我收到这个错误:
ERROR在[默认] C:\ xampp\htdocs\meriem-car\public\src\app\components\administration.component.ts:12:4类型'{moduleId:string; selector:string; 指令:typeof LoginComponent []; templateUrl:string; }'不能分配给'Component'类型的参数.对象文字只能指定已知属性,"组件"类型中不存在"指令".
这是我的代码:
this._api.getCompanies().subscribe(
res => this.companies = JSON.parse(res),
exception => {if(this._api.responseErrorProcess(exception)) { // in case this retured TRUE then I need to retry() } }
)
Run Code Online (Sandbox Code Playgroud)
如果发生异常,它将被发送到API中的函数,然后true在问题得到修复时返回(例如,令牌刷新),并且只需要在修复后再次重试
我无法弄清楚如何让它重试.
这是我在实现时获得的自动生成函数之一
SensorEventListener
我已经搜索过了,并且没有找到这个描述:"如果传感器精度发生变化,请做点什么." 接近传感器精度何时以及如何变化?这对我的应用程序有什么用?
这是我的代码:
this._http.post(this._url_get + extension, '', { headers: headers })
.map(res => res['_body'])
.retryWhen(errors => {return responseErrorProcess(errors)})
Run Code Online (Sandbox Code Playgroud)
现在我需要捕获异常并将它们传递给我responseErrorProcess(),true如果它需要重试则返回
我无法弄清楚如何从中检索异常errors,这是它的样子:
Subject_isScalar: falseclosed: falsehasError: falseisStopped: falseobservers: Array[0]thrownError: null__proto__: Observable`
Run Code Online (Sandbox Code Playgroud)
它似乎没有包含有关发生的异常的错误,而且我无法弄清楚应该返回什么以便实际重试.
我正在尝试在我的组件之间进行某种通信,所以我在组件中使用带有BehaviorSubject和Subscription的服务,如下所示:
服务(与问题相关的代码):
import { BehaviorSubject } from 'rxjs/BehaviorSubject'
private _clientModalActionSource = new BehaviorSubject<string>('')
modalAction$ = this._clientModalActionSource.asObservable()
public updateClientModalAction(action) {
this._clientModalActionSource.next(action)
console.log('sent')
}
Run Code Online (Sandbox Code Playgroud)
组件A:
this._api.updateClientModalAction(id)
Run Code Online (Sandbox Code Playgroud)
组件B:
import { Subscription } from 'rxjs/subscription'
private _subscription: Subscription
ngOnInit() { this._subscription = this._api.modalAction$.subscribe(res => {
this.refreshModal(res)
console.log('received')
})}
Run Code Online (Sandbox Code Playgroud)
如果组件B是组件A的子组件,这是完美的工作,但如果A是根组件而B在其内部<router-outlet>(或相反),则订阅的任何内容都没有,我只能进入sent控制台.
我究竟做错了什么?