简体   繁体   中英

Problems with data service and ionic

I'm creating a new Ionic app using Backand to host the data. I want to present a list of all the instruments I have in a database. Here's my presentation code:

<!--    Create tabs with an icon and label, using the tabs-positive style.
        Each tab's child <ion-nav-view> directive will have its own
        navigation history that also transitions its views in and out.  --> 
<ion-tabs class="tabs-icon-top tabs-color-active-positive"> 
  <ion-tab title="Instruments"  icon="ion-home"href="#/tabs/dashboard"> 
    <ion-nav-viewname="tab-dashboard"></ion-nav-view>     
  </ion-tab> 
  <ion-tab title="Login"icon="ion-log-in"href="#/tabs/login"> 
    <ion-nav-viewname="tab-login"></ion-nav-view>     
  </ion-tab>   
</ion-tabs>

And my Instrument service is:

service('InstrumentsModel', function ($http, Backand) { 
  var service = this, baseUrl = '/1/objects/', objectName = 'items/';
  functiongetUrl() {
    return Backand.getApiUrl() + baseUrl + objectName; 
  } 
  functiongetUrlForId(id) {
    return getUrl() + id; 
  } 
  service.all = function() {
    return $http.get(getUrl());
  };
  // rest of the service here
})

The problem I'm seeing is that I don't think I've hooked the code up correctly. How do I get my app to use my InstrumentsModel data service?"

Make sure you specified your data service correctly in the Angular controller. The controller is used to drive the UI, so if it is pointing at the wrong code then you're not going to get up-to-date events. You didn't post your controller name, so I can't point you at the specific file - something like controllers/instruments_controller.js

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