In a Windows Phone 7.1 emulator with PhoneGap 3.0 and AngularJS 1.2, why does this not work:
angulargap.controller('HomeController', ['$scope', '$routeParams', '$location',
function ($scope, $routeParams, $location) {
$scope.$routeParams = $routeParams;
$scope.$location = $location;
$scope.message = "AngularJS!";
}]);
Error message:
ERROR:Error: [$injector:cdep] Circular dependency found:
http://errors.angularjs.org/1.2.0-rc.2/$injector/cdep?p0=
While this works:
angulargap.controller('HomeController', ['$scope', '$routeParams',
function ($scope, $routeParams) {
$scope.$routeParams = $routeParams;
$scope.message = "AngularJS!";
}]);
What is going wrong with injecting the $location service in this specific scenario? All works great in Chrome and Internet Explorer in a desktop browser. But it does not work in the Windows Phone 7 device emulator, nor on the physical device itself.
Got it guys ... There is a substantial amount of issues for the AngularJS/PhoneGap/WindowsPhone combination. This one was solved by https://github.com/angular/angular.js/issues/2303?source=cc#issuecomment-20770025.
Essentially, because windows phone uses a weird protocol prefix with a single forward slash (x-wmapp0:/)
, the $location initializer goes nuts and that triggers an error which seamingly exposes itself in this weird error message, completely unrelated to the error :-(
I'm about to propose a pull-request on this fix to the AngularJS repo on GitHub.