简体   繁体   中英

Ionic2 ion-content not render content

I try using ion-content as:

<ion-content>
    <ion-list>
        <button ion-item *ngFor="let item of items" (click)="itemTapped($event, item)" class="list-item">
            <img class="picture" src="/build/images/profile/{{item.picture}}" item-left/>
            <div class="item-data">
                <div>
                    <span class="title">{{item.title}}</span>
                    <span class="sub-title">{{item.typeWork}}</span>
                    <span class="distance"><ion-icon name="map" item-right></ion-icon>{{item.distance}} km</span>
                </div>
                <div class="evaluation">
                    <span><ion-icon name="cash"></ion-icon>{{item.noteAveragePrice}}</span>
                    <span><ion-icon name="ribbon"></ion-icon>{{item.noteAverageService}}</span>
                    <span><ion-icon name="clock"></ion-icon>{{item.noteAverageScore}}</span>
                </div>
            </div>
            <!--
            <span class="description">{{item.description}}</span>
            -->
        </button>
    </ion-list>
    <div *ngIf="selectedItem" padding>
        You navigated here from <b>{{selectedItem.title}}</b>
    </div>
</ion-content>

And not render content:

在此处输入图片说明

When remove the ion-content tag the content is displayed, but not contain scrolling

在此处输入图片说明

I found the problem, i used in the controller of class for view (with ion-content) @Component instead of @Page . After change for @Page works for me.

Before

import {Component, ViewChild} from '@angular/core';
import {NavController, Alert, Content} from 'ionic-angular';
import {ProfessionalModel} from './professional-model';

@Component({
    templateUrl: 'build/pages/professional/professional-view.html'
})

After

import {ViewChild} from '@angular/core';
import {NavController, Alert, Content, Page} from 'ionic-angular';
import {ProfessionalModel} from './professional-model';

@Page({
    templateUrl: 'build/pages/professional/professional-view.html'
})

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM