[英]Error injecting the angularjs $location service
I am trying to inject the $location service in the following code snippet: 我正在尝试在以下代码片段中注入$ location服务:
<script type="text/javascript">
var $injector = angular.injector(['ng', 'kinvey', 'app.constants']);
$injector.invoke(['$kinvey', 'CONST','URI_PATH', function($kinvey, CONST, URI_PATH) {
$kinvey.init({
appKey : CONST.appKey,
appSecret : CONST.appSecret
}).then(function() {
console.log("success to connect");
angular.bootstrap(document, ['app']);
}, function() {
angular.bootstrap(document, ['app']);
});
}]);
</script>
I am unable to inject the $location service in the above script. 我无法在上述脚本中注入$ location服务。 This script is in my index.html file which contains my
<ng-view></ng-view>
just to paint a better mental picture of the page structure. 这个脚本在我的index.html文件中,该文件包含我的
<ng-view></ng-view>
只是为了更好地描绘页面结构。
Did yoy try to use the $locationProvider?, and then $locationProvider.$get(). 是不是尝试使用$ locationProvider ?,然后使用$ locationProvider。$ get()。
$location service is not available before Angular bootstraps fully since only in the config phase of the app the services are instantiated using their corresponding providers. $ location服务在Angular完全引导之前不可用,因为仅在应用程序的配置阶段,服务才使用其相应的提供程序实例化。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.