简体   繁体   中英

How to print objects to screen user using Ionic2

I have an API with several values inside. I want to show the values on my screen to the user using kind of label or something. Array with objects

Each object has some values like lat and longitude: Object

How can I show lat and long of each object in a sentence to user? Like: "Your location was: + ..value.. + lat and + ..value.. + long

If you are using angular2 and ionic2 you have to use ngFor directive to run over array and ionic2 ion-list component, so an example of this could be:

<ion-list>
  <ion-item *ngFor="let object of array">

   {{"Your location was:" + object.location + "lat:" + object.lat}}
  </ion-item>
</ion-list>

You can use ng-repeat to display list of lat and long and for the labelling you can use cards

<ion-list ng-controller="MyCtrl" can-swipe="true">
  <ion-item ng-repeat="obj in arrays"  class="item-thumbnail-left">
     <ion-card>
        <ion-card-content>
           "Your location was: {{obj.location.lat}} lat and {{obj.location.lng}}  long 
        </ion-card-content>
    </ion-card>      
  </ion-item>
</ion-list>

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