1
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 url provided by the user to be loaded by 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: If I use the code:
window.open(url, '_self', 'location=no');
I can open the pages normally, but I am using the first alternative to validate whether the URL is valid or not before loading an invalid page for the user. Any idea what might be going on?
I believe something is missing, try angular.module('Coffeeforce.controllers',['ngCordova'])
– André Vicente