数据服务和离子的问题

Problems with data service and ionic

本文关键字:问题 服务 数据      更新时间:2023-09-26

我正在使用Backand创建一个新的Ionic应用程序来托管数据。我想在数据库中列出我拥有的所有仪器。这是我的演示代码:

<!--    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>

我的仪器服务是:

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
})

我看到的问题是,我认为我没有正确地连接代码。如何让我的应用程序使用我的InstrumentsModel数据服务?"

确保在Angular控制器中正确指定了数据服务。控制器用于驱动UI,因此如果它指向错误的代码,则无法获得最新的事件。你没有公布你的控制器名称,所以我不能把你指向特定的文件,比如controllers/instruments_controller.js