I\'m trying to load a local json with http.get() in angular 2. I tried something, that I found here on stack. It looks like this:
this is my app.m
I you want to put the response of the request in the navItems. Because http.get() return an observable you will have to subscribe to it.
Look at this example:
// version without map
this.http.get("../data/navItems.json")
.subscribe((success) => {
this.navItems = success.json();
});
// with map
import 'rxjs/add/operator/map'
this.http.get("../data/navItems.json")
.map((data) => {
return data.json();
})
.subscribe((success) => {
this.navItems = success;
});