i can't get json data in my model
What I have tried:
this is my app.component.ts
<pre>import { Component, OnInit } from '@angular/core';
import { RecordsService } from './records.service';
import { map } from 'rxjs/operators';
import {Observable} from 'rxjs';
import { ArrayType } from '@angular/compiler';
export interface RootObject {
data: Data;
}
export interface Data {
altMenuListe: AltMenuListe2[];
}
export interface AltMenuListe2 {
ustMenuId: number;
menuAd: string;
isLeaf: boolean;
leaf: number;
altMenuListe: AltMenuListe[];
}
export interface AltMenuListe {
ustMenuId: number;
menuAd: string;
isLeaf: boolean;
leaf: number;
altMenuListe: any[];
}
@Component({
selector: 'app-root',
templateUrl: './app.component.html',
styleUrls: ['./app.component.css']
})
export class AppComponent {
records: any;
title = 'Angular Rest Api Test';
constructor(private myFirstService: RecordsService) {
}
ngOnInit() {
this.myFirstService.getData()
.subscribe(dataS => {
this.records = dataS.data;
console.log(this.records);
});
}
}
this is my service.ts
import { Injectable } from '@angular/core';
import { HttpClient } from '@angular/common/http';
import { Data } from './app.component';
import { AltMenuListe2 } from './app.component';
import { AltMenuListe } from './app.component';
import { RootObject } from './app.component';
@Injectable()
export class RecordsService {
constructor(private http: HttpClient) {}
getData() {
return this.http.get
<RootObject>
('http://192.168.12.10:8088/sistemApi/menuGetir?_dc=1534489724075');
}
}
this is my json
{
"data" : {
"altMenuListe" : [ {
"ustMenuId" : 2,
"menuAd" : "Birim Kapat",
"isLeaf" : true,
"leaf" : 1,
"altMenuListe" : [ {
"ustMenuId" : 2,
"menuAd" : "Birim Kapat",
"isLeaf" : true,
"leaf" : 1,
"altMenuListe" : [ ]
}, {
"ustMenuId" : 2,
"menuAd" : "Birim Kapat",
"isLeaf" : true,
"leaf" : 1,
"altMenuListe" : [ ]
}, {
"ustMenuId" : 2,
"menuAd" : "Birim Kapat",
"isLeaf" : true,
"leaf" : 1,
"altMenuListe" : [ ]
}, {
"ustMenuId" : 2,
"menuAd" : "Birim Kapat",
"isLeaf" : true,
"leaf" : 1,
"altMenuListe" : [ ]
}, {
"ustMenuId" : 2,
"menuAd" : "Birim Kapat",
"isLeaf" : true,
"leaf" : 1,
"altMenuListe" : [ ]
}, {
"ustMenuId" : 2,
"menuAd" : "Birim Kapat",
"isLeaf" : true,
"leaf" : 1,
"altMenuListe" : [ ]
}, {
"ustMenuId" : 2,
"menuAd" : "Birim Kapat",
"isLeaf" : true,
"leaf" : 1,
"altMenuListe" : [ ]
}, {
"ustMenuId" : 2,
"menuAd" : "Birim Kapat",
"isLeaf" : true,
"leaf" : 1,
"altMenuListe" : [ ]
}, {
"ustMenuId" : 2,
"menuAd" : "Birim Kapat",
"isLeaf" : true,
"leaf" : 1,
"altMenuListe" : [ ]
}, {
"ustMenuId" : 2,
"menuAd" : "Birim Kapat",
"isLeaf" : true,
"leaf" : 1,
"altMenuListe" : [ ]
}, {
"ustMenuId" : 2,
"menuAd" : "Birim Kapat",
"isLeaf" : true,
"leaf" : 1,
"altMenuListe" : [ ]
}, {
"ustMenuId" : 2,
"menuAd" : "Birim Kapat",
"isLeaf" : true,
"leaf" : 1,
"altMenuListe" : [ ]
}, {
"ustMenuId" : 2,
"menuAd" : "Birim Kapat",
"isLeaf" : true,
"leaf" : 1,
"altMenuListe" : [ ]
}, {
"ustMenuId" : 2,
"menuAd" : "Birim Kapat",
"isLeaf" : true,
"leaf" : 1,
"altMenuListe" : [ ]
}, {
"ustMenuId" : 2,
"menuAd" : "Birim Kapat",
"isLeaf" : true,
"leaf" : 1,
"altMenuListe" : [ ]
}, {
"ustMenuId" : 2,
"menuAd" : "Birim Kapat",
"isLeaf" : true,
"leaf" : 1,
"altMenuListe" : [ ]
} ]
} ]
}
}