angularionic-frameworkwakanda

Wakanda How to access and display the data in mobile side?


In the getting started on Wakanda it explain how I can bind my data in my web app via AngularJs.

http://wakanda.github.io/get-started/bind-data-in-webapp.html

The mobile app work with Ionic 2, and I want to know, how I can bind the data like the web app ?

My goal is to have the same result as the getting started but on the mobile side. Anyone can help me ?


Solution

  • You can achieve the same result in Ionic 2 project by using the wakanda.service. all you have to do is :

    1. In home.ts for example

      import { Wakanda } from '../../app/wakanda.service';

    2. Add Wakanda to providers array

      @Component({ selector: 'page-home', providers: [Wakanda], templateUrl: 'home.html' })

    3. Add Wakanda to the constructor

      constructor(public navCtrl: NavController, public wakanda: Wakanda) {}

    4. You can use the service like this :

      getHeros() { this.wakanda.getCatalog().then(ds => { ds['Superhero'].query({orderBy:"ID desc",pageSize:3}).then(collection => { this.favoriteSuperheroes = collection.entities; }); }); }

    5. Display heros in home.html :

      <ion-content padding> <button ion-button (click)= getHeros()>Display Heros</button> <ion-list> <ion-item *ngFor="let superhero of favoriteSuperheroes">{{superhero.name}} </ion-item> </ion-list> </ion-content>

    For more informations about how to interact with Wakanda Server REST API please refer to this link Wakanda JavaScript Client