Search code examples
ionic2backand

How to setup Backand SDK in an Ionic2 app?


I'd like to setup my Ionic2 app to use the Backand SDK. I am new to Ionic2 / Angular2 and I couldn't find any example out there with an Ionic2 app. I could only find example apps with Ionic1 / Angular1 apps which don't help me.

Any clues?

Thanks, Guillaume


Solution

  • As Aaron said, you can take 'backandService.ts' file from /app/service folder in my repository at

    https://github.com/backand/ionic2-crud-example

    Here you have direct link to file.

    If you are using Typescript, you will be able to load it with this snippet:

    import {BackandService} from '../../services/backandService'
    

    Inject BackandService in you constructor:

    constructor(public backandService:BackandService) {   
    }
    

    And do login like this:

    this.backandService.getAuthTokenSimple(this.username, this.password);
    

    And then post data with this code:

    this.backandService.postItem(this.name)