离子。如何将ionicPlatform注入服务? [英] Ionic. How inject ionicPlatform into the service?

查看:253
本文介绍了离子。如何将ionicPlatform注入服务?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想在服务中注入 $ ionicPlatform 抽象,但似乎我做错了。我应该如何使用 $ ionicPlatform 服务?

I'd like to inject $ionicPlatform abstraction into the service, but seemed I'm doing this wrong way. How should I use $ionicPlatform with service?

(function () {
    "use strict";
    angular.module('service', []).service('BBNService', ["$ionicPlatform", function ($http, $localStorage, $ionicPlatform) {

此代码使$ ionicPlatform未定义。

This code making $ionicPlatform undefined.

推荐答案

注入离子依赖性&如果您不按如下方式使用,则删除$ http,

Inject ionic dependency & Remove $http if you not using it as follows,

 angular.module('service', ['ionic'])
   .service('BBNService', ["$localStorage", "$ionicPlatform", 
       function ($localStorage, $ionicPlatform) {
   }]);

这篇关于离子。如何将ionicPlatform注入服务?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆