2
votes

I am trying to implement HTTPS(with server certificate, placed in platform->android->asset as defined in cordova-HTTP plugin documention) web service for Hybrid application.I have successfully added the cordova plugin for android platform.I have loaded the module in my app.js:

angular.module('app', ['ionic', 'app.controllers', 'app.routes', 'app.services', 'app.directives'])

Now i am trying to use it in controller.js

angular.module('app.controllers', ['cordovaHTTP'])
  .controller('loginScreenCtrl', function($scope) {
    console.log('inside Test App controller');
    $scope.ShowAlert = function() {
      console.log('inside onButtonClick');
      cordovaHTTP.enableSSLPinning(true, function() {
        console.log('success!');
    }, function() {
        console.log('error :(');
});

but i have got "Failed to instantiate module app.controllers due to: Error: [$injector:modulerr] Failed to instantiate module cordovaHTTP due to: Error: [$injector:nomod] Module 'cordovaHTTP' is not available! You either misspelled the module name or forgot to load it. If registering a module ensure that you specify the dependencies as the second argument." exception

Let me know any suggestion for the same

1
you missed to implement following: please replace: angular.module('app', ['ionic', 'app.controllers', 'app.routes', 'app.services', 'app.directives']) with angular.module('app', ['ionic', 'app.controllers', 'app.routes', 'app.services', 'app.directives', 'cordovaHTTP' ])Naitik
@Naitik : I have replaced the line as suggested by you but got below error: Failed to instantiate module app due to: Error: [$injector:modulerr] Failed to instantiate module app.controllers due to: Error: [$injector:modulerr] Failed to instantiate module cordovaHTTP due to: Error: [$injector:nomod] Module 'cordovaHTTP' is not available! You either misspelled the module name or forgot to load it. If registering a module ensure that you specify the dependencies as the second argument.Yogesh Chander
remove and add github.com/wymsee/cordova-HTTP plugin again. May be your plugin is not installed properlyNaitik
I have gotten below plugin list using "cordova plugin list" command:==== cordova-plugin-compat 1.0.0 "Compat" cordova-plugin-dialogs 1.2.1 "Notification" cordova-plugin-file 4.2.0 "File" cordova-plugin-http 1.1.0 "SSL Pinning" cordova-plugin-whitelist 1.2.2 "Whitelist"Yogesh Chander
please remove cordova-plugin-http 1.1.0 which is version old please update new version 1.2.0 of cordova-plugin-http by following command: cordova plugin rm cordova-plugin-http and cordova plugin add cordova-plugin-httpNaitik

1 Answers

1
votes

Add dependency

cordovaHTTP

in app.js

angular.module('app', ['ionic', 'app.controllers', 'app.routes', 'app.services', 'app.directives', 'cordovaHTTP'])

Hope that solves your problem.

Regards.