Quantcast
Channel: Ionic Forum - Latest topics
Viewing all articles
Browse latest Browse all 70612

Need help with $rootscope and $cordovaNetwork

$
0
0

@mathiasRobinson wrote:

Hello, ive been working on an app for a while now with a few plugins added.
But the app cant function properly without connection, so i wanted to add the $cordovaNetwork

But here comes my problem all the sudden.
when i add the $cordovaNetwork or $rootscope to my controller i keep getting an Unknown provider
.controller('loginCtrl', ['$scope', '$state', '$ionicHistory', '$localstorage', '$http', 'Auth', 'Login', '$cordovaNetwork', function ($scope, $state, $ionicHistory, $localstorage, $http, Auth, Login, $cordovaNetwork) { .... }

Error: [$injector:unpr] Unknown provider: $cordovaNetworkProvider <- $cordovaNetwork <- loginCtrl

// Ionic Starter App

// angular.module is a global place for creating, registering and retrieving Angular modules
// 'starter' is the name of this angular module example (also set in a <body> attribute in index.html)
// the 2nd parameter is an array of 'requires'
// 'starter.controllers' is found in controllers.js
angular.module('starter', ['ionic', 'starter.controllers', 'starter.services'])

.factory('$localstorage', ['$window', function ($window) {
    return {
        set: function (key, value) {
            $window.localStorage[key] = value;
        },
        get: function (key, defaultValue) {
            return $window.localStorage[key] || defaultValue;
        },
        setObject: function (key, value) {
            $window.localStorage[key] = JSON.stringify(value);
        },
        getObject: function (key) {
            return JSON.parse($window.localStorage[key] || '{}');
        },
        removeObject: function (key) {
            $window.localStorage.removeItem(key);
        }
    }
}])

.run(function ($ionicPlatform) {
    if (window.StatusBar) {
        StatusBar.hide();
    }
    $ionicPlatform.ready(function () {
        // Hide the accessory bar by default (remove this to show the accessory bar above the keyboard
        // for form inputs)
        if (window.cordova && window.cordova.plugins.Keyboard) {
            cordova.plugins.Keyboard.hideKeyboardAccessoryBar(true);
            cordova.plugins.Keyboard.disableScroll(true);

        }
        if (window.StatusBar) {
            StatusBar.hide();
        }

    });
})

.config(function ($stateProvider, $urlRouterProvider, $ionicConfigProvider) {
    $stateProvider
      .state('app', {
          url: '/app',
          abstract: true,
          templateUrl: 'templates/menu.html',
          controller: 'AppCtrl',
          onEnter: function ($state, Auth, Contacts) {
              if (!Auth.isLoggedIn()) {
                  $state.go('login');
              }
          }
      })
    .state('app.main', {
        url: '/main',
        views: {
            'menuContent': {
                templateUrl: 'templates/main.html',
                controller: 'mainCtrl'
            }
        }
    })
    .state('login', {
        url: '/login',
        templateUrl: "templates/login.html",
        controller: 'loginCtrl',
        onEnter: function ($state, Auth) {
            if (Auth.isLoggedIn()) {
                $state.go('app.main');
            }
        }
    });
    // if none of the above states are matched, use this as the fallback
    $urlRouterProvider.otherwise('login');

    $ionicConfigProvider.views.maxCache(0);
});

so please what am i doing wrong?

Posts: 8

Participants: 2

Read full topic


Viewing all articles
Browse latest Browse all 70612

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>