{"action":"closed","issue":{"url":"https://api.github.com/repos/angular/angular-cli/issues/1309","repository_url":"https://api.github.com/repos/angular/angular-cli","labels_url":"https://api.github.com/repos/angular/angular-cli/issues/1309/labels{/name}","comments_url":"https://api.github.com/repos/angular/angular-cli/issues/1309/comments","events_url":"https://api.github.com/repos/angular/angular-cli/issues/1309/events","html_url":"https://github.com/angular/angular-cli/issues/1309","id":164674234,"number":1309,"title":"how to serve json data during ng serve?","user":{"login":"kamran-pervaiz","id":2331946,"avatar_url":"https://avatars.githubusercontent.com/u/2331946?v=3","gravatar_id":"","url":"https://api.github.com/users/kamran-pervaiz","html_url":"https://github.com/kamran-pervaiz","followers_url":"https://api.github.com/users/kamran-pervaiz/followers","following_url":"https://api.github.com/users/kamran-pervaiz/following{/other_user}","gists_url":"https://api.github.com/users/kamran-pervaiz/gists{/gist_id}","starred_url":"https://api.github.com/users/kamran-pervaiz/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/kamran-pervaiz/subscriptions","organizations_url":"https://api.github.com/users/kamran-pervaiz/orgs","repos_url":"https://api.github.com/users/kamran-pervaiz/repos","events_url":"https://api.github.com/users/kamran-pervaiz/events{/privacy}","received_events_url":"https://api.github.com/users/kamran-pervaiz/received_events","type":"User","site_admin":false},"labels":[],"state":"closed","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":2,"created_at":"2016-07-09T16:28:45Z","updated_at":"2016-07-10T13:20:50Z","closed_at":"2016-07-10T13:20:50Z","body":"Hi,\r\n\r\nI have created an angular 2 app and i am trying to create a service to send json data on UI.\r\n\r\nStructure\r\n- app\r\n- app/data/countries.json\r\n\r\n> [\r\n>     { 'id': '1', 'name': 'United Kingdom' },\r\n>     { 'id': '2', 'name': 'United States' },\r\n>     { 'id': '3', 'name': 'India' },\r\n>     { 'id': '4', 'name': 'Pakistan' }\r\n> ]\r\n\r\n- factory/factory.service\r\n\r\n> import { Injectable } from '@angular/core';\r\n> import { Http, Response} from '@angular/http';\r\n> import { Observable } from 'rxjs/Observable';\r\n> \r\n> import { IDictionary } from '../shared/dictionary';\r\n> \r\n> @Injectable()\r\n> export class FactoryService {\r\n>     private countryUrl = \"../data/countries.json\";\r\n> \r\n>     constructor(private http: Http) {\r\n>         \r\n>     }\r\n> \r\n>     getCountry(): Observable<IDictionary[]> {\r\n>         return this.http.get(this.countryUrl)\r\n>             .map((response: Response) => <IDictionary[]>response.json())\r\n>             .do(data => console.log(\"Countries: \" + JSON.stringify(data)))\r\n>             .catch(this.handleError);\r\n>     }\r\n> \r\n>     private handleError(error: Response) {\r\n>         console.log(error);\r\n>         return Observable.throw(error.json().error || \"500 internal server error\");\r\n>     }\r\n> }\r\n\r\n- IDictionary\r\n\r\n> export interface IDictionary {\r\n>     [index: string]: string\r\n> }\r\n\r\n- factory/factory-form.component.ts\r\n\r\n>\r\n> export class FactoryFormComponent implements OnInit {\r\n> \r\n>     private model: Factory;\r\n>     countries;\r\n>     factoryStatuses;\r\n>     productTypes;\r\n>     risks;\r\n>     private errorMessage: string;\r\n>     private submitted = false;\r\n> \r\n>     constructor(private factoryService: FactoryService) {\r\n>         \r\n>     }\r\n> \r\n>     ngOnInit(): void {\r\n>         this.countries = this.factoryService.getCountry()\r\n>             .subscribe(countries => this.countries = countries, error => this.errorMessage = error);\r\n>         this.factoryStatuses = this.factoryService.getFactoryStatusDummy();\r\n>         this.productTypes = this.factoryService.getProductTypeDummy();\r\n>         this.risks = this.factoryService.getFactoryRiskDummy();\r\n>     }\r\n> \r\n> }\r\n\r\nI have noticed when i open the app in chrome, its missing the data folder although i put it in \"app/data\" in system.config.js\r\n\r\n![image](https://cloud.githubusercontent.com/assets/2331946/16708938/7a47666e-45fa-11e6-8366-0e2cc529bc8d.png)\r\n\r\n\r\nError:\r\n\r\n![image](https://cloud.githubusercontent.com/assets/2331946/16709045/75f44160-45fd-11e6-9c35-31b277bebfaa.png)\r\n\r\ndo i need to do some extra stuff to make data folder as part of my app?"}}
{"actor":{"display_login":"kamran-pervaiz"}}