来自JSON Array的Ionic 3 navPush

时间:2017-12-05 20:40:01

标签: ionic-framework ionic3

我在我的Ionic应用程序中有一个根页面,我正在使用JSON文件构建。我需要在数组中放置一个页面对象并让navPush选择器获取值,但它不起作用。如果我将页面硬编码到navPush中它可以工作,但不是从JSON中提取。

listingPage

...
<ion-row class="grid-categories">
  <ion-col width-50 class="category-item" *ngFor="let category of listing.categories">
    <background-image class="category-heading" [src]="category.image" [navPush]="category.page">
      <ion-row class="heading-row">
        <ion-col no-padding width-100>
          <h2 class="category-title">{{category.title}}</h2>
        </ion-col>
      </ion-row>
    </background-image>
  </ion-col>
</ion-row>
...

category.imagecategory.title可以正常工作,但不能category.page - 如果我删除category.page并添加aboutPage,它可以正常工作,但当然所有链接都会得到到aboutPage。

listing.json

...
"categories": [
    {
        "title": "About MSNVM",
        "image": "./assets/images/listing/200x200basquet.png",
        "page": "aboutPage"
    },
    {
        "title": "Plaque Locator",
        "image": "./assets/images/listing/200x200boxeo.png",
        "page": "aboutPage"
    },
    {
        "title": "Make A Donation",
        "image": "./assets/images/listing/200x200crossfit.png",
        "page": "aboutPage"
    },
    {
        "title": "Visit Memorial",
        "image": "./assets/images/listing/200x200futbol.png",
        "page": "aboutPage"
    }

]
...

1 个答案:

答案 0 :(得分:1)

它不应该是"page": "AboutPage"吗? (资本A,因为它的类名称)