2

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 ?

CoCoNours
  • 233
  • 1
  • 2
  • 13

1 Answers1

1

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

issam Eljohri
  • 322
  • 1
  • 6
  • Thank you for your answer, I just have a a little problem, I can't compile. I have this following message: "Property 'favoriteSuperhero' does not exist on type 'HomePage'." I don't know why, in my backend I have the right name (I see in Quickstart they write Supehero instead of Superhero). – CoCoNours Apr 18 '17 at 07:59
  • I try something else with your link, for exemple when I try a "Find" I have this following message: "Property 'Company' does not exist on type 'Catalog'." the Autocompletion don't work so I don't have access to my database. Do you know why ? – CoCoNours Apr 18 '17 at 10:19
  • For the first comment you need to declare favoriteSuperheroes = []; in the class HomePage, before the getHeros function – issam Eljohri Apr 18 '17 at 10:53