import {Injectable} from '@angular/core'; import {Http, Response} from '@angular/http'; import {Headers, RequestOptions} from '@angular/http'; import {Observable} from 'rxjs/Rx'; import {CommunityInfo} from '../community/communityInfo'; @Injectable() export class CommunitiesService { constructor(private http:Http) { } getCommunities(url: string) { return this.http.get(url).map(res => res.json()).map(res => this.parseCommunities(res)); } parseCommunities(data: any): CommunityInfo[] { let communities: CommunityInfo[] = []; let length = Array.isArray(data) ? data.length :1; for (let i=0; i(); } let managers = resData[0].managers; let length = Array.isArray(managers) ? managers.length : 1; for(let i=0; i(); } let subjects = resData[0].subjects; let length = Array.isArray(subjects) ? subjects.length : 1; for(let i=0; i(); } let managers = resData.managers; let length = Array.isArray(managers) ? managers.length : 1; for(let i=0; i(); } let subjects = resData.subjects; let length = Array.isArray(subjects) ? subjects.length : 1; for(let i=0; i