Skip to content

I will get data from my nested json file with httpclient and i have a problem #29

Open

Description

@Hbahmani
import { Component, OnInit  } from '@angular/core';
import { RecordsService } from './records.service';
// tslint:disable-next-line:import-blacklist
import { map } from 'rxjs/operators';
import {Observable} from 'rxjs';
import { ArrayType } from '@angular/compiler';
// tslint:disable-next-line:prefer-const

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';
  // tslint:disable-next-line:use-life-cycle-interface
  constructor(private myFirstService: RecordsService) {
  }
  // tslint:disable-next-line:use-life-cycle-interface
  ngOnInit() {
     this.myFirstService.getData()
     .subscribe(dataS => {
      this.records = dataS.data;
      console.log(this.records);
    });
 }
}


this is my service.ts

Hide   Copy Code
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
        
        ('http://192.168.12.10:8088/sistemApi/menuGetir?_dc=1534489724075');
    }

}


this is my json

Hide   Expand    Copy Code


{
  "okundu" : "okunmadi",
  "degisti" : "",
  "menuId" : null,
  "ustMenuId" : null,
  "projeFormId" : null,
  "menuSira" : null,
  "menuKod" : null,
  "menuAd" : "I-DEAL Menü",
  "menuSimge" : null,
  "menudeTiklan" : null,
  "menuFavori" : null,
  "isLeaf" : null,
  "leaf" : null,
  "versionId" : null,
  "icon" : null,
  "altMenuListe" : null,
  "altMenu" : [ {
    "okundu" : "okunmadi",
    "degisti" : "",
    "menuId" : 1,
    "ustMenuId" : 0,
    "projeFormId" : null,
    "menuSira" : 11,
    "menuKod" : null,
    "menuAd" : "Sistem Yönetimi",
    "menuSimge" : "fa-cogs",
    "menudeTiklan" : false,
    "menuFavori" : false,
    "isLeaf" : false,
    "leaf" : 0,
    "versionId" : 2,
    "icon" : "http://localhost:8080/dealResources/images/simge/16x16/klasor.jpg",
    "altMenuListe" : null,
    "altMenu" : [ {
      "okundu" : "okunmadi",
      "degisti" : "",
      "menuId" : 321,
      "ustMenuId" : 1,
      "projeFormId" : 1,
      "menuSira" : 1,
      "menuKod" : "sistem.bilgisayar.BilgisayarView",
      "menuAd" : "Bilgisayar Kayıtları",
      "menuSimge" : null,
      "menudeTiklan" : true,
      "menuFavori" : false,
      "isLeaf" : true,
      "leaf" : 1,
      "versionId" : 0,
      "icon" : "http://localhost:8080/dealResources/images/simge/16x16/form.jpg",
      "altMenuListe" : null,
      "altMenu" : [ ]
    }, {
      "okundu" : "okunmadi",
      "degisti" : "",
      "menuId" : 335,
      "ustMenuId" : 1,
      "projeFormId" : 3,
      "menuSira" : 4,
      "menuKod" : "sistem.bolge.BolgeView",
      "menuAd" : "Bölge Tanımları",
      "menuSimge" : null,
      "menudeTiklan" : true,
      "menuFavori" : false,
      "isLeaf" : true,
      "leaf" : 1,
      "versionId" : 0,
      "icon" : "http://localhost:8080/dealResources/images/simge/16x16/form.jpg",
      "altMenuListe" : null,
      "altMenu" : [ ]
    }, {
      "okundu" : "okunmadi",
      "degisti" : "",
      "menuId" : 342,
      "ustMenuId" : 1,
      "projeFormId" : 24,
      "menuSira" : 5,
      "menuKod" : "sistem.menukayit.MenuKayitTree",
      "menuAd" : "Ağaç Menu Düzenleme",
      "menuSimge" : null,
      "menudeTiklan" : true,
      "menuFavori" : false,
      "isLeaf" : true,
      "leaf" : 1,
      "versionId" : 0,
      "icon" : "http://localhost:8080/dealResources/images/simge/16x16/form.jpg",
      "altMenuListe" : null,
      "altMenu" : [ ]
    }, {
      "okundu" : "okunmadi",
      "degisti" : "",
      "menuId" : 348,
      "ustMenuId" : 1,
      "projeFormId" : 30,
      "menuSira" : 6,
      "menuKod" : "sistem.kullaniciyetki.KullaniciYetkiView",
      "menuAd" : "Kullanıcı Yetki Tanımları",
      "menuSimge" : null,
      "menudeTiklan" : true,
      "menuFavori" : false,
      "isLeaf" : true,
      "leaf" : 1,
      "versionId" : 0,
      "icon" : "http://localhost:8080/dealResources/images/simge/16x16/form.jpg",
      "altMenuListe" : null,
      "altMenu" : [ ]
    }, {
      "okundu" : "okunmadi",
      "degisti" : "",
      "menuId" : 352,
      "ustMenuId" : 1,
      "projeFormId" : 34,
      "menuSira" : 2,
      "menuKod" : "sistem.guncelle.SistemGuncelleForm",
      "menuAd" : "Sistem Güncelle",
      "menuSimge" : null,
      "menudeTiklan" : true,
      "menuFavori" : false,
      "isLeaf" : true,
      "leaf" : 1,
      "versionId" : 0,
      "icon" : "http://localhost:8080/dealResources/images/simge/16x16/form.jpg",
      "altMenuListe" : null,
      "altMenu" : [ ]
    }, {
      "okundu" : "okunmadi",
      "degisti" : "",
      "menuId" : 353,
      "ustMenuId" : 1,
      "projeFormId" : 35,
      "menuSira" : 7,
      "menuKod" : "sistem.menukayit.MenuKayitView",
      "menuAd" : "Sistem Form Tanımları",
      "menuSimge" : null,
      "menudeTiklan" : true,
      "menuFavori" : false,
      "isLeaf" : true,
      "leaf" : 1,
      "versionId" : 0,
      "icon" : "http://localhost:8080/dealResources/images/simge/16x16/form.jpg",
      "altMenuListe" : null,
      "altMenu" : [ ]
    }, {
      "okundu" : "okunmadi",
      "degisti" : "",
      "menuId" : 395,
      "ustMenuId" : 1,
      "projeFormId" : 89,
      "menuSira" : 9,
      "menuKod" : "sistem.yazici.YaziciView",
      "menuAd" : "Anket Tanımları",
      "menuSimge" : null,
      "menudeTiklan" : true,
      "menuFavori" : false,
      "isLeaf" : true,
      "leaf" : 1,
      "versionId" : 0,
      "icon" : "http://localhost:8080/dealResources/images/simge/16x16/form.jpg",
      "altMenuListe" : null,
      "altMenu" : [ ]
    }, {
      "okundu" : "okunmadi",
      "degisti" : "",
      "menuId" : 412,
      "ustMenuId" : 1,
      "projeFormId" : 105,
      "menuSira" : 10,
      "menuKod" : "cvBankasi.CvForm.CvView",
      "menuAd" : "CV Tanımlama",
      "menuSimge" : null,
      "menudeTiklan" : true,
      "menuFavori" : false,
      "isLeaf" : true,
      "leaf" : 1,
      "versionId" : 0,
      "icon" : "http://localhost:8080/dealResources/images/simge/16x16/form.jpg",
      "altMenuListe" : null,
      "altMenu" : [ ]
    }, {
      "okundu" : "okunmadi",
      "degisti" : "",
      "menuId" : 417,
      "ustMenuId" : 1,
      "projeFormId" : 111,
      "menuSira" : 3,
      "menuKod" : "sistem.yonetim.ProjeAyarlari",
      "menuAd" : "Proje Parametre Ayarları",
      "menuSimge" : null,
      "menudeTiklan" : true,
      "menuFavori" : false,
      "isLeaf" : true,
      "leaf" : 1,
      "versionId" : 0,
      "icon" : "http://localhost:8080/dealResources/images/simge/16x16/form.jpg",
      "altMenuListe" : null,
      "altMenu" : [ ]
    }, {
      "okundu" : "okunmadi",
      "degisti" : "",
      "menuId" : 493,
      "ustMenuId" : 1,
      "projeFormId" : 239,
      "menuSira" : 11,
      "menuKod" : "sistem.cariYilDonem.CariYilDonemView",
      "menuAd" : "Cari Yıl Dönem Formu",
      "menuSimge" : null,
      "menudeTiklan" : true,
      "menuFavori" : false,
      "isLeaf" : true,
      "leaf" : 1,
      "versionId" : 0,
      "icon" : "http://localhost:8080/dealResources/images/simge/16x16/form.jpg",
      "altMenuListe" : null,
      "altMenu" : [ ]
    }, {
      "okundu" : "okunmadi",
      "degisti" : "",
      "menuId" : 504,
      "ustMenuId" : 1,
      "projeFormId" : 255,
      "menuSira" : 12,
      "menuKod" : "DealKurulumView",
      "menuAd" : "Deal Kurulumları",
      "menuSimge" : null,
      "menudeTiklan" : true,
      "menuFavori" : false,
      "isLeaf" : true,
      "leaf" : 1,
      "versionId" : 0,
      "icon" : "http://localhost:8080/dealResources/images/simge/16x16/form.jpg",
      "altMenuListe" : null,
      "altMenu" : [ ]
    }, {
      "okundu" : "okunmadi",
      "degisti" : "",
      "menuId" : 513,
      "ustMenuId" : 1,
      "projeFormId" : 264,
      "menuSira" : 13,
      "menuKod" : "sistem.etiket.EtiketView",
      "menuAd" : "Etiket Form",
      "menuSimge" : null,
      "menudeTiklan" : true,
      "menuFavori" : false,
      "isLeaf" : true,
      "leaf" : 1,
      "versionId" : 0,
      "icon" : "http://localhost:8080/dealResources/images/simge/16x16/form.jpg",
      "altMenuListe" : null,
      "altMenu" : [ ]
    }, {
      "okundu" : "okunmadi",
      "degisti" : "",
      "menuId" : 662,
      "ustMenuId" : 1,
      "projeFormId" : 50,
      "menuSira" : 8,
      "menuKod" : "stok.stokRecete.StokReceteView",
      "menuAd" : "Stok Reçete Tanımları",
      "menuSimge" : null,
      "menudeTiklan" : true,
      "menuFavori" : false,
      "isLeaf" : true,
      "leaf" : 1,
      "versionId" : 0,
      "icon" : "http://localhost:8080/dealResources/images/simge/16x16/form.jpg",
      "altMenuListe" : null,
      "altMenu" : [ ]
    }, {
      "okundu" : "okunmadi",
      "degisti" : "",
      "menuId" : 674,
      "ustMenuId" : 1,
      "projeFormId" : 343,
      "menuSira" : 18,
      "menuKod" : "stok.cikisIslemleri.BirimKapatForm",
      "menuAd" : "Birim Kapat",
      "menuSimge" : null,
      "menudeTiklan" : true,
      "menuFavori" : false,
      "isLeaf" : true,
      "leaf" : 1,
      "versionId" : 0,
      "icon" : "http://localhost:8080/dealResources/images/simge/16x16/form.jpg",
      "altMenuListe" : null,
      "altMenu" : [ ]
    }, {
      "okundu" : "okunmadi",
      "degisti" : "",
      "menuId" : 675,
      "ustMenuId" : 1,
      "projeFormId" : 345,
      "menuSira" : 14,
      "menuKod" : "sistem.birim.BirimGunKontrolView",
      "menuAd" : "Birim Gün Saat Kontrolleri",
      "menuSimge" : null,
      "menudeTiklan" : true,
      "menuFavori" : false,
      "isLeaf" : true,
      "leaf" : 1,
      "versionId" : 0,
      "icon" : "http://localhost:8080/dealResources/images/simge/16x16/form.jpg",
      "altMenuListe" : null,
      "altMenu" : [ ]
    }, {
      "okundu" : "okunmadi",
      "degisti" : "",
      "menuId" : 710,
      "ustMenuId" : 1,
      "projeFormId" : 389,
      "menuSira" : 15,
      "menuKod" : "portal.kimlikGrup.SohbetGrupView",
      "menuAd" : "Sohbet Kimlik Grup Tanımları ",
      "menuSimge" : null,
      "menudeTiklan" : true,
      "menuFavori" : false,
      "isLeaf" : true,
      "leaf" : 1,
      "versionId" : 0,
      "icon" : "http://localhost:8080/dealResources/images/simge/16x16/form.jpg",
      "altMenuListe" : null,
      "altMenu" : [ ]
    } ]
  }, {
    "okundu" : "okunmadi",
    "degisti" : "",
    "menuId" : 2,
    "ustMenuId" : 0,
    "projeFormId" : null,
    "menuSira" : 9,
    "menuKod" : null,
    "menuAd" : "Kullanıcı Yönetimi",
    "menuSimge" : "fa-users",
    "menudeTiklan" : false,
    "menuFavori" : false,
    "isLeaf" : false,
    "leaf" : 0,
    "versionId" : 1,
    "icon" : "http://localhost:8080/dealResources/images/simge/16x16/klasor.jpg",
    "altMenuListe" : null,
    "altMenu" : [ {
      "okundu" : "okunmadi",
      "degisti" : "",
      "menuId" : 322,
      "ustMenuId" : 2,
      "projeFormId" : 5,
      "menuSira" : 1,
      "menuKod" : "kullanici.kullaniciGrup.KullaniciGrupView",
      "menuAd" : "Kullanıcı Grup Tanımları",
      "menuSimge" : null,
      "menudeTiklan" : true,
      "menuFavori" : false,
      "isLeaf" : true,
      "leaf" : 1,
      "versionId" : 1,
      "icon" : "http://localhost:8080/dealResources/images/simge/16x16/form.jpg",
      "altMenuListe" : null,
      "altMenu" : [ ]
    }, {
      "okundu" : "okunmadi",
      "degisti" : "",
      "menuId" : 435,
      "ustMenuId" : 2,
      "projeFormId" : 6,
      "menuSira" : 2,
      "menuKod" : "kullanici.kullaniciRol.KullaniciRolView",
      "menuAd" : "Kullanıcı Rol Tanımları",
      "menuSimge" : null,
      "menudeTiklan" : true,
      "menuFavori" : false,
      "isLeaf" : true,
      "leaf" : 1,
      "versionId" : 1,
      "icon" : "http://localhost:8080/dealResources/images/simge/16x16/form.jpg",
      "altMenuListe" : null,
      "altMenu" : [ ]
    }, {
      "okundu" : "okunmadi",
      "degisti" : "",
      "menuId" : 436,
      "ustMenuId" : 2,
      "projeFormId" : 4,
      "menuSira" : 3,
      "menuKod" : "kullanici.kullaniciMain.KullaniciMainView",
      "menuAd" : "Kullanıcı Kayıtları",
      "menuSimge" : null,
      "menudeTiklan" : true,
      "menuFavori" : false,
      "isLeaf" : true,
      "leaf" : 1,
      "versionId" : 1,
      "icon" : "http://localhost:8080/dealResources/images/simge/16x16/form.jpg",
      "altMenuListe" : null,
      "altMenu" : [ ]
    } ]
  }
 } ]
  } ]
}

Activity

  1. Hbahmani commented on Aug 18, 2018

    @Hbahmani
    Author

    is there anybody help me?

  2. bhanu7755 commented on Aug 20, 2018

    @bhanu7755
    Contributor

    What error are you getting?

  3. Hbahmani commented on Aug 20, 2018

    @Hbahmani
    Author
  4. bhanu7755 commented on Aug 20, 2018

    @bhanu7755
    Contributor

    Have you added your service in Providers section in app.module.ts?

  5. Hbahmani commented on Aug 20, 2018

    @Hbahmani
    Author
  6. Hbahmani commented on Aug 20, 2018

    @Hbahmani
    Author
  7. Hbahmani commented on Aug 20, 2018

    @Hbahmani
    Author

    actually my app is working just doesn't bring full data

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions