Search
 
SCRIPT & CODE EXAMPLE
 

JAVASCRIPT

angular load json file with httpclient

import { HttpClient } from '@angular/common/http'; 
import { Observable } from 'rxjs';

@Injectable()
export class AppSettingsService {

   constructor(private http: HttpClient) {
        this.getJSON().subscribe(data => {
            console.log(data);
        });
    }

    public getJSON(): Observable<any> {
        return this.http.get("./assets/mydata.json");
    }
}
Comment

PREVIOUS NEXT
Code Example
Javascript :: npm uniqueid 
Javascript :: settext javascript 
Javascript :: flip a coin javascript 
Javascript :: get form data serialize jquery 
Javascript :: mongodb findOneAndUpdate return updated 
Javascript :: convert array of string to array of objects javascript 
Javascript :: javascript compare arrays remove duplicates 
Javascript :: datatable get all selected row data 
Javascript :: jquery select attribute 
Javascript :: how to add text to h2 with jquery 
Javascript :: add element to array javascript 
Javascript :: plotly js y axis range 
Javascript :: stackoverflow narrate text js 
Javascript :: node convert buffer to string 
Javascript :: jquery select a dynamic element 
Javascript :: how to convert string to lowercase in javascript 
Javascript :: javascript backslash 
Javascript :: joi or null 
Javascript :: javascript check if array has duplicate values 
Javascript :: js first letter to uppercase 
Javascript :: url in js 
Javascript :: __dirname is not defined 
Javascript :: make event nodejs 
Javascript :: jquery find by data attribute 
Javascript :: current date minus days javascript 
Javascript :: permutation javascript 
Javascript :: element ui handle enter key 
Javascript :: json array to string in postgresql 
Javascript :: javascript remove object property 
Javascript :: await useeffect javascript 
ADD CONTENT
Topic
Content
Source link
Name
1+8 =