注入angularjs $ location服务时出错

时间:2014-02-22 16:24:09

标签: javascript angularjs

我正在尝试在以下代码段中注入$ 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>

我无法在上面的脚本中注入$ location服务。这个脚本在我的index.html文件中,其中包含我的<ng-view></ng-view>,只是为了描绘页面结构的更好的心理图。

此外,我收到以下错误:link

1 个答案:

答案 0 :(得分:0)

您是否尝试使用$ locationProvider?,然后$ locationProvider。$ get()。

在Angular引导之前,$ location服务不可用,因为仅在应用程序的配置阶段,服务使用其相应的提供程序进行实例化。