小编Mot*_* MK的帖子

Angular 2.0版本:管道和指令不再是@Component的属性

我刚刚将我在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'类型的参数.对象文字只能指定已知属性,"组件"类型中不存在"指令".

angular-directive angular-pipe angular

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

angular2/RxJS - 如何从subscribe()内部重试

这是我的代码:

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在问题得到修复时返回(例如,令牌刷新),并且只需要在修复后再次重试

我无法弄清楚如何让它重试.

observable rxjs angular2-observables angular

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

onAccuracyChanged,为什么?

这是我在实现时获得的自动生成函数之一

SensorEventListener

我已经搜索过了,并且没有找到这个描述:"如果传感器精度发生变化,请做点什么." 接近传感器精度何时以及如何变化?这对我的应用程序有什么用?

android android-sensors proximitysensor

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

如何使用retryWhen使用返回布尔值的函数?

这是我的代码:

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)

它似乎没有包含有关发生的异常的错误,而且我无法弄清楚应该返回什么以便实际重试.

rxjs rxjs5 angular2-observables angular

2
推荐指数
2
解决办法
5473
查看次数

Angular2 + RxJS BehaviorSubject订阅不适用于所有组件

我正在尝试在我的组件之间进行某种通信,所以我在组件中使用带有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控制台.

我究竟做错了什么?

rxjs behaviorsubject angular2-services angular

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

angular2 - 如何导入 LocalStorage

所以我是 Angular2 的新手,我一直在尝试按照教程进行身份验证

当我导入 localstorage 时,我在代码编辑器中收到此错误

在此输入图像描述

我想它必须先安装吧?但我不知道如何

谢谢。

local-storage angular2-localstorage angular

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