I have the following code:
<input type="text" id="input-url" name="input-url" placeholder="URL do Servidor">
<button class="button button-block button-dark" ng-controller="AppCtrl"
ng-click="openBrowser()">Definir</button>
javascript code:
angular.module('CoffeeForce.controllers',[])
.controller('AppCtrl', function($scope, $cordovaInAppBrowser, $http, messageFactory) {
var options = {
location: 'no',
clearcache: 'yes',
toolbar: 'no'
};
$scope.openBrowser = function() {
inputUrl = document.getElementById("input-url").value;
$cordovaInAppBrowser.open(inputUrl, '_self', options)
.then(function(event) {
console.log("success");
})
.catch(function(event) {
console.log("Error")
});
});
Basically, I need a user-supplied url to be loaded by the inAppBrowser plugin, however, the following error occurs:
ionic.bundle.js:26794 Error: [$injector:unpr] Unknown provider: $cordovaInAppBrowserProvider <- $cordovaInAppBrowser <- AppCtrl
http://errors.angularjs.org/1.5.3/$injector/unpr?p0=%24cordovaInAppBrowserProvider%20%3C-%20%24cordovaInAppBrowser%20%3C-%20AppCtrl
at ionic.bundle.js:13438
at ionic.bundle.js:17788
at Object.getService [as get] (ionic.bundle.js:17941)
at ionic.bundle.js:17793
at getService (ionic.bundle.js:17941)
at injectionArgs (ionic.bundle.js:17965)
at Object.invoke (ionic.bundle.js:17987)
at $controllerInit (ionic.bundle.js:23397)
at nodeLinkFn (ionic.bundle.js:22335)
at compositeLinkFn (ionic.bundle.js:21703)
Note: I used the code:
window.open(url, '_self', 'location=no');
I can open pages normally, but I'm using the first alternative to validate whether or not the URL is valid before loading an invalid page to the user. Any idea what might be happening?