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'; import{EnvProperties} from '../../utils/properties/env-properties'; @Injectable() export class CommunitiesService { constructor(private http:Http) { } getCommunities(properties:EnvProperties, url: string) { return this.http.get((properties.useCache)? (properties.cacheUrl+encodeURIComponent(url)) : 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