相关疑难解决方法(0)

.filter不是Angular2的函数

EXCEPTION: TypeError: articles.filter is not a function 我的服务出错了

import {Injectable} from 'angular2/core';
import {Http} from 'angular2/http';
import 'rxjs/Rx';

 @Injectable()

 export class ArticlesService {
     http:Http;
     constructor(http:Http) {
     this.http = http;
    }

getArticle(id: number) {
return Promise.resolve('./articles.json').then(
  articles => articles.filter(article => article.id === id)[0]
     );
  }
 }
Run Code Online (Sandbox Code Playgroud)

我的Plunker但在"英雄之旅"中它运作良好

angular

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

标签 统计

angular ×1