hoerresb / WifiWizard

A Cordova plugin for managing Wifi networks
Apache License 2.0
205 stars 177 forks source link

How to inject the plugin #60

Open ghost opened 8 years ago

ghost commented 8 years ago

Hello, how can I inject the plugin into my application config? I would like to let the application to set the wifi password if it is installed. I have this code on application configuration.

´´´

var happyApp = angular.module('happyApp', [ 'ionic', 'ngRoute', 'happyControllers', 'pascalprecht.translate', 'ionic.utils', 'api' ]);

happyApp.config(function($stateProvider, $urlRouterProvider, $translateProvider){

if(window.localStorage['country_value']!=null && window.localStorage['store_number']!=null){
    $urlRouterProvider.otherwise('/');
}else{
    $urlRouterProvider.otherwise('/setup');
}

console.log("test"+WifiWizard.formatWPAConfig('DKT_3','Cp-Spain'));

$stateProvider.state('index', {
    url: '/',
    templateUrl: './views/faceIndex.html',
    controller: 'faceIndexCtrl'
});
$stateProvider.state('setup', {
    url: '/setup',
    templateUrl: './views/setup.html',
    controller: 'setupCtrl'
});
$stateProvider.state('logout', {
    url: '/logout',
    templateUrl: './views/logout.html',
    controller: 'logoutCtrl'
});
$translateProvider
    .useStaticFilesLoader({
        prefix: 'translations/',
        suffix: '.json'
    })
    .registerAvailableLanguageKeys(['en', 'es', 'de', 'fr', 'it'], {
    'en-US': 'en',
    'es-ES': 'es',
    'de-DE': 'de',
    'fr-FR': 'fr',
    'it-IT': 'it',
});
$translateProvider.preferredLanguage(window.localStorage['country_value']);
$translateProvider.fallbackLanguage(window.localStorage['country_value']);

});

´´´

But when I start the application the console give me undefined error in image

image

Error: [$injector:unpr] Unknown provider: WifiWizard

Can you help me please?

ismavolk commented 8 years ago

Same issue here, but with ionic framework

ghost commented 8 years ago

Hello, now it work, I use command to clean cordova, and now it works fine. Regards

ismavolk commented 8 years ago

Hi, I tried the cordova clean command, but continued with the same problem. I update the cordova and the project, but did not work either.

Thanks

joseangelmr commented 8 years ago

Hi, I'm developing an app ionic, I want to use wifiwizard plugin, but: WifiWizard is not defined. it's compatible WifiWizard with ionic? . Regards

ifbbprochris commented 8 years ago

when I ran it in chrome it said WifiWizard is not defined,but it worked when I ran android

do it support ios?

webarthur commented 8 years ago

+1

zho commented 7 years ago

u need to make sure the platform is ready, not need to inject in controller...

$ionicPlatform.ready(function() {
      WifiWizard.getCurrentSSID(function success(result){
....
luisAzcuaga commented 6 years ago

Guys, the wifiWizard is made only for Android/iOS (it's on the readme) and for using it (besides installing it) you need to declare it outside your class as declare var WifiWizard: any; Then you can use it inside any method as WifiWizard.getCurrentSSID(functionHandler(ssid),errcatcher(err:any))

Hope it helps you :)