我想在Apache Cordova中运行我的示例Angular代码,但似乎在独立Angular中工作的东西在使用Apache Cordova时无法在Visual Studio中工作。。工厂不能在Visual Studio的Cordova中工作
该方法取自Scott Allen在Pluralsight的AngularJS教程。我在'独立'角度使用它,它工作:http://plnkr.co/edit/P12BG2eDaCR7PsNzGGFV。但为什么不在科尔多瓦?
我有两个文件:
(function() {
var req = function ($http) {
var getTest = function (username) {
return $http.get("https://api.github.com/users/" + username)
.then(function (response) {
return response.data;
});
};
return {
getTest: getTest
};
};
var module = angular.module("starter.controllers");
module.factory("req", req);
}());
和
angular.module('starter.controllers', [])
.controller('BrowseCtrl', function ($scope, $stateParams, req) {
var myTest = req.getTest("test");
});
不幸的是我最终得到
Error: [$injector:unpr] Unknown provider: reqProvider <- req <- BrowseCtrl
所有与此相关的错误,我发现的问题进行了相关的reintialisation该模块通过添加“[]”,但这不是这里的情况。