我正在使用 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 Controller 中正确指定了数据服务。 Controller 用于驱动 UI,因此如果它指向错误的代码,那么您将无法获得最新的事件。您没有发布您的 Controller 名称,因此我无法向您指出特定文件 - 例如controllers/instruments_controller.js
关于javascript - 数据服务和 ionic 问题,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/34392612/