Yogesh Chander
Yogesh Chander

Reputation: 129

How to inject cordovaHTTP plugin with Angular

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

Upvotes: 2

Views: 762

Answers (1)

Hardik Vaghani
Hardik Vaghani

Reputation: 2173

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.

Upvotes: 1

Related Questions