bagaimana cara menampilkan data json pada array di ionic?

bagaimana cara memunculkan data json yang memiliki id yang sama dalam sebuah array, di ionic. Contohnya saya memiliki data json sebagai berikut :

{"data":[{"id":"1","category_id":"1","name":"Eden Catering","address":"57-45 Parsons Blvd. Flushing, NY 11365","icon":"vendor-1.jpg","category":"Catering"},{"id":"2","category_id":"1","name":"Love Catering","address":"Jl Kamboja no.135","icon":"vendor-2.jpg","category":"Catering"},{"id":"3","category_id":"1","name":"Bali Wedding Catering","address":"Jl Lembayung Senja no.12","icon":"vendor-3.jpg","category":"Catering"},{"id":"4","category_id":"1","name":"Charisma Food","address":"Jl Lorem Ipsum no 4","icon":"vendor-1.jpg","category":"Catering"},{"id":"5","category_id":"2","name":"Shanti Video","address":"Jl Dolor sit Amet no.55","icon":"vendor-1.jpg","category":"Photo & Video"},{"id":"6","category_id":"2","name":"Nirvana Photo Studio","address":"Jl Ingradium Laviosa no.222","icon":"vendor-1.jpg","category":"Photo & Video"},{"id":"7","category_id":"2","name":"Lampion Photo","address":"13 Velvet Extension, Pole Cat Crossing","icon":"vendor-3.jpg","category":"Photo & Video"},{"id":"8","category_id":"3","name":"Love Florist","address":"4023 Fallen Cider Impasse","icon":"vendor-2.jpg","category":"Decoration\/Florist"},{"id":"9","category_id":"3","name":"Chipmunk Decor","address":"57-45 Parsons Blvd. Flushing, NY 11365","icon":"vendor-1.jpg","category":"Decoration\/Florist"},{"id":"10","category_id":"3","name":"Triangle Decoration","address":"1508 Cotton Brook Trail","icon":"vendor-2.jpg","category":"Decoration\/Florist"},{"id":"11","category_id":"3","name":"Jhon Troy Flowers","address":"Jl Ingradium Laviosa no.90","icon":"vendor-3.jpg","category":"Decoration\/Florist"},{"id":"12","category_id":"4","name":"Agar-Agar Gift","address":"Jl Sunda Kelapa Blok E-45","icon":"vendor-1.jpg","category":"Souvenir & Invitation"},{"id":"13","category_id":"4","name":"Wed Souvenirs","address":"Jl Lorem Ipsum no 4","icon":"vendor-2.jpg","category":"Souvenir & Invitation"},{"id":"14","category_id":"4","name":"Triangle Decoration","address":"Apartemen Bioton Blok A-4","icon":"vendor-3.jpg","category":"Souvenir & Invitation"},{"id":"15","category_id":"5","name":"Wedding Fashion","address":"Jl Ingradium Laviosa no.124 B-C","icon":"vendor-3.jpg","category":"Fashion"},{"id":"16","category_id":"5","name":"Girl Go Fashion","address":"Sriwedari Apt. no.6C","icon":"vendor-1.jpg","category":"Fashion"},{"id":"17","category_id":"5","name":"Bride Style","address":"Jl Lorem Ipsum no 345","icon":"vendor-2.jpg","category":"Fashion"},{"id":"18","category_id":"5","name":"Bride n Groom Fashion","address":"Jl Sunset Road no 77","icon":"vendor-1.jpg","category":"Fashion"},{"id":"19","category_id":"5","name":"Lucy Wedding Gown","address":"4023 Fallen Cider Impasse","icon":"vendor-3.jpg","category":"Fashion"}]}

saya hanya ingin menampilkan data yang memiliki category_id= 1

mhon bantuannya :)

avatar ayupa
@ayupa

5 Kontribusi 2 Poin

Diperbarui 8 tahun yang lalu

7 Jawaban:

Ane asumsikan, kalo agan scopenya sudah disambungkan, tinggal pake ngif pas loop datanya

pake ng-if di cek apakah category id nya satu atau bukan

 <div ng-if="category.id === 1">

lengkapnya

 ion-list>
  <ion-item ng-repeat="data in datas" href="#">
    {{data.name}} {{data.id}}
    <!-- bagian ini yang filter -->
      <ion-item ng-repeat="test in tests" href="#" ng-if="data.category_id === 1">
          {{test.name}} {{test.cat_id}}
      </ion-item>
  </ion-item>
</ion-list>
avatar immeng
@immeng

10 Kontribusi 18 Poin

Dipost 8 tahun yang lalu

kok ndak mau ya kak?, ini saya coba lampirkan code di controller sama servicenya

code yang kemarin kk kirim saya buatnya di html mhon bantuannya kak

terima kasih

avatar ayupa
@ayupa

5 Kontribusi 2 Poin

Dipost 8 tahun yang lalu

@ayupa 1.ngga bisanya keluar semua atau error? kalo error , errornya apa gan tulisannya, 2. di console udah keluar ya datanya? 3. Dilampirkan juga kode buat viewnya, mungkin ada yang salah disana

avatar immeng
@immeng

10 Kontribusi 18 Poin

Dipost 8 tahun yang lalu

1. ndak mau muncul kaka 2. di console sudh mau uncul datanya 3.

mhon pencerahannya kak terimakasih

avatar ayupa
@ayupa

5 Kontribusi 2 Poin

Dipost 8 tahun yang lalu

0. Kalau ngga pake ng-if apa sudah keluar semua? kalo belum berarti salahnya bukan di ng-ifnya 1. Kalo buka inspect-element di browser, bagian console, errornya apa tulisannya? 2. Coba ganti === jadi dua samadengan ==, terus lihat lagi errornya

avatar immeng
@immeng

10 Kontribusi 18 Poin

Dipost 8 tahun yang lalu

1. kalo ndak pake ng-if bisa keluar semua kak 2. di console ndak ad error kak 3. sudah tak ganti kak,, tapi masih blum mau dan tidak ada error kak

avatar ayupa
@ayupa

5 Kontribusi 2 Poin

Dipost 8 tahun yang lalu

sudah bisa kak,, ternyata saya sala masukin variabelnya :D terima kasih banyak kak atas bimbingannya

avatar ayupa
@ayupa

5 Kontribusi 2 Poin

Dipost 8 tahun yang lalu

Login untuk ikut Jawaban