# Opening pages with ngFor

**URL:** <https://forum.ionicframework.com/t/opening-pages-with-ngfor/167671>\
**Category:** ionic-v3\
**Created:** [July 2, 2019, 8:22am UTC](https://forum.ionicframework.com/t/opening-pages-with-ngfor/167671 "2019-07-02T08:22:10Z")\
**Posts on this page:** 10\
**Page:** 1

<div class="post-metadata">

**Author:** ![Tubiss](https://sea1.discourse-cdn.com/ionicframework/user_avatar/forum.ionicframework.com/tubiss/32/127043_2.png) [@Tubiss](https://forum.ionicframework.com/u/Tubiss)\
**Post date:** [July 2, 2019, 8:22am UTC](https://forum.ionicframework.com/t/opening-pages-with-ngfor/167671/1 "2019-07-02T08:22:10Z")

</div>

ı am stuck on for using two ngFor .

home.html

\<ion-content \*ngFor=“let item of items”\>  
  
  
  
\<ion-col col \*ngFor=“let person of people” (click)=“openPage(item)”\>

  
 ![]()  

{{person.lesson\_d.name}}

  

home.ts

items=[

```
   {,component:'FirstPage'},
   {component:'secondPage'},
   {component:'thirdPage'},
   {,component:'fourthPage'},
 
 ]

```

openPage(page){

```
  this.navCtrl.setRoot(page.component); 
  }

```

my code like this.But when ı am running everthing is okey except opening always “fourthPage”.  
İn every item opening same page which is “fourthPage”  
so please help me.

---

<div class="post-metadata">

**Author:** ![ankant](https://avatars.discourse-cdn.com/v4/letter/a/e99b99/32.png) [@ankant](https://forum.ionicframework.com/u/ankant)\
**Post date:** [July 3, 2019, 9:03am UTC](https://forum.ionicframework.com/t/opening-pages-with-ngfor/167671/2 "2019-07-03T09:03:07Z")

</div>

Can you try this

```auto
<ion-list *ngFor=“let item of items”>
      {{item.component}}
      <ion-item *ngFor="let person of people” (click)="“openPage(item)">
            {{person.lesson_d.name}}
      </ion-item>
 </ion-list>

```

---

<div class="post-metadata">

**Author:** ![Tubiss](https://sea1.discourse-cdn.com/ionicframework/user_avatar/forum.ionicframework.com/tubiss/32/127043_2.png) [@Tubiss](https://forum.ionicframework.com/u/Tubiss)\
**Post date:** [July 3, 2019, 1:09pm UTC](https://forum.ionicframework.com/t/opening-pages-with-ngfor/167671/3 "2019-07-03T13:09:05Z")

</div>

thank you for answer but didnt work .  
output like this.

firstPage  
abc  
edf  
secondPage  
abc  
edf  
thirdPage  
abc  
edf  
fourthPage  
abc  
edf

plaase help me

---

<div class="post-metadata">

**Author:** ![VictorNorman](https://sea1.discourse-cdn.com/ionicframework/user_avatar/forum.ionicframework.com/victornorman/32/124743_2.png) [@VictorNorman](https://forum.ionicframework.com/u/VictorNorman)\
**Post date:** [July 3, 2019, 1:56pm UTC](https://forum.ionicframework.com/t/opening-pages-with-ngfor/167671/4 "2019-07-03T13:56:33Z")

</div>

the problem may be because you are generating multiple `<ion-content>` tags. There should be only one per page: [https://ionicframework.com/docs/api/content](https://ionicframework.com/docs/api/content)

Hope this helps.

---

<div class="post-metadata">

**Author:** ![Tubiss](https://sea1.discourse-cdn.com/ionicframework/user_avatar/forum.ionicframework.com/tubiss/32/127043_2.png) [@Tubiss](https://forum.ionicframework.com/u/Tubiss)\
**Post date:** [July 3, 2019, 2:33pm UTC](https://forum.ionicframework.com/t/opening-pages-with-ngfor/167671/5 "2019-07-03T14:33:32Z")

</div>

ı just used only one ion-content tag.  
ı dont know what is the wrong.  
please help me.

---

<div class="post-metadata">

**Author:** ![VictorNorman](https://sea1.discourse-cdn.com/ionicframework/user_avatar/forum.ionicframework.com/victornorman/32/124743_2.png) [@VictorNorman](https://forum.ionicframework.com/u/VictorNorman)\
**Post date:** [July 3, 2019, 7:23pm UTC](https://forum.ionicframework.com/t/opening-pages-with-ngfor/167671/6 "2019-07-03T19:23:58Z")

</div>

When you put an \*ngFor loop in a tag you’ll end up with multiple of those tags. E.g.,

```auto
<ion-list *ngFor="let item of items">

```

will generate one `<ion-list>` tag for each item in items. So, if you put

```auto
<ion-content *ngFor="let x of someList">

```

you’ll get multiple `<ion-content>` tags generated.

---

<div class="post-metadata">

**Author:** ![ankant](https://avatars.discourse-cdn.com/v4/letter/a/e99b99/32.png) [@ankant](https://forum.ionicframework.com/u/ankant)\
**Post date:** [July 4, 2019, 4:07am UTC](https://forum.ionicframework.com/t/opening-pages-with-ngfor/167671/7 "2019-07-04T04:07:11Z")

</div>

So persons and items are independent sets of data. Can you explain what you are trying to do with items and persons?

---

<div class="post-metadata">

**Author:** ![Tubiss](https://sea1.discourse-cdn.com/ionicframework/user_avatar/forum.ionicframework.com/tubiss/32/127043_2.png) [@Tubiss](https://forum.ionicframework.com/u/Tubiss)\
**Post date:** [July 4, 2019, 6:21am UTC](https://forum.ionicframework.com/t/opening-pages-with-ngfor/167671/8 "2019-07-04T06:21:24Z")

</div>

people is my json array which ı want to display in the page. Item is my page array which ı want to push for each person. But every person go to same page . I want to push different pages. please help me.

---

<div class="post-metadata">

**Author:** ![ankant](https://avatars.discourse-cdn.com/v4/letter/a/e99b99/32.png) [@ankant](https://forum.ionicframework.com/u/ankant)\
**Post date:** [July 4, 2019, 6:27am UTC](https://forum.ionicframework.com/t/opening-pages-with-ngfor/167671/9 "2019-07-04T06:27:33Z")

</div>

Do you want to display the list of people on the home page? and then when u click on a person name, which page should it navigate to?  
If you are looking to use nested ngFor loops, you need to first workout on how to loop over items and persons first. Then you could use ion-list and ion-item and do something like this

```auto
<ion-list *ngFor=“let person of people”>
      {{person.lesson_d.name}}
      <ion-item *ngFor="let item of items” (click)="“openPage(item)">
            {{person.lesson_d.name}} {{item.component}}
      </ion-item>
 </ion-list>

```

---

<div class="post-metadata">

**Author:** ![Tubiss](https://sea1.discourse-cdn.com/ionicframework/user_avatar/forum.ionicframework.com/tubiss/32/127043_2.png) [@Tubiss](https://forum.ionicframework.com/u/Tubiss)\
**Post date:** [July 4, 2019, 6:51am UTC](https://forum.ionicframework.com/t/opening-pages-with-ngfor/167671/10 "2019-07-04T06:51:10Z")

</div>

I solved my problem like this.

\<ion-col col \*ngFor=“let person of people; let i=index” \>

 ![]()

{{person.lesson\_d.name}}

thank you for your answer
