Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- [
- "{'id': 1, 'building': 'Edificio 4', 'zone': 'Sin zonas', 'floor': 1, 'school': 1}",
- "{'id': 2, 'building': 'Edificio 15', 'zone': 'Sin zonas', 'floor': 0, 'school': 1}",
- "{'id': 3, 'building': 'Edificio 15', 'zone': 'Sin zonas', 'floor': 1, 'school': 1}",
- "{'id': 4, 'building': 'Edificio 2', 'zone': 'C', 'floor': 2, 'school': 2}",
- "{'id': 5, 'building': 'Edificio 2', 'zone': 'B', 'floor': 3, 'school': 2}",
- "{'id': 6, 'building': 'Edificio 7', 'zone': 'J', 'floor': 7, 'school': 2}"
- ]
- import { Component, OnInit, ViewEncapsulation } from '@angular/core';
- import { Observable } from 'rxjs/Rx';
- import { Injectable } from '@angular/core';
- import { HttpClient } from '@angular/common/http';
- //this is the data class
- class Place{
- constructor(public id: string, public building: string, public zone: string, public floor: string, public school: string) { }
- }
- @Component({
- selector: 'app-locker',
- template: `
- //here i have a template
- `,
- styleUrls: ['./locker.component.css'],
- })
- @Injectable()
- export class LockerComponent implements OnInit {
- places: Place[];
- //if I manually add the data by hand here it works,
- //I want to fetch the JSON data to this array
- campus: String;
- building: String;
- floor: String;
- zone: String;
- type: String;
- buildings = [];
- floors = [];
- zones = [];
- types = [];
- constructor(private http: HttpClient) {}
- ngOnInit(): void {
- this.http.get('./assets/test.json').subscribe(data => {
- this.places = data;
- });
- }
- }
Add Comment
Please, Sign In to add comment