简体   繁体   English

数据服务和离子问题

[英]Problems with data service and ionic

I'm creating a new Ionic app using Backand to host the data. 我正在使用Backand创建一个新的Ionic应用程序来托管数据。 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?" 如何让我的应用使用我的InstrumentsModel数据服务?”

Make sure you specified your data service correctly in the Angular controller. 确保在Angular控制器中正确指定了数据服务。 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. 控制器用于驱动UI,因此,如果它指向错误的代码,则不会获得最新的事件。 You didn't post your controller name, so I can't point you at the specific file - something like controllers/instruments_controller.js 您没有发布控制器名称,所以我无法将您指向特定文件-类似于controllers / instruments_controller.js

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM