基本的Javascript过滤函数在Angular2中不能正常工作
Basic Javascript filter function not working correctly in Angular2
这应该非常简单,但是我在Typescript中的过滤器函数一直给我一个错误。下面是我的代码:
highScores: HighScore[];
deletePlayer(email: string) {
this.scoreDataService.deletePlayer(email)
.subscribe(
this.highScores = this.highScores.filter(highScore => highScore.email !== email)
);
}
过滤器函数应该简单地返回一个数组HighScore[],但相反,我一直得到这个错误:
Argument of type 'HighScore[] is not assignable to parameter of type 'NextObserver<Response> | ErrorObserver<Response> | CompletionObserver<Response> ...
Type 'HighScore[]' is not assignable to type '(value: Response) => void'. Tyope 'HighScore[]' provides no match for the signature '(value:Response): void'
最奇怪的是,即使有这个错误,这段代码也能完美地运行和工作。有人知道会发生什么吗?提前感谢!
subscribe
期望一个函数参数:
this.scoreDataService.deletePlayer(email)
.subscribe(() => {
this.highScores = this.highScores.filter(highScore => highScore.email !== email)
});
相关文章:
- AngularJS UI路由器不能像ng路由器那样工作
- HTML5音频加载和播放获胜'我不能在iPad上工作
- JS可以在Chrome中工作,但不能在Firefox中工作
- javascript扫雷器floodfill算法不能正常工作
- JavaScript指令不能像我想象的那样工作
- Facebook登录按钮没有'不能在Firefox上工作
- jQuery Datepicker可以在Safari中工作,但不能在FF或Chrome中工作
- javascript没有´我不能在joomla 3.0中工作
- 用javascript将script元素附加到头部;铬不能工作
- jQuery函数不能只在一个页面上工作
- 为什么这个代码不能正常工作
- 为什么jquery悬停在jsfiddle中可以工作,而在我的html布局中却不能
- 为什么我的JavaScript在Safari上的严格模式下不能正常工作
- 为什么Turbolinks不能正常工作?Rails应用程序
- jQuery dosn'内联函数不能按预期工作
- 为什么这个javascript工作不能正确地分配.cells[] ?
- 谷歌应用引擎云端点:OAuth2不工作.不能加载api
- 输入焦点不工作/不能选择单选按钮-引导
- LocalStorage不能在iPhone上工作-不能在私人浏览
- 工作不能代替生活