[英]Error injecting the angularjs $location service
我正在嘗試在以下代碼片段中注入$ 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>
只是為了更好地描繪頁面結構。
我也收到以下錯誤: 鏈接
是不是嘗試使用$ locationProvider ?,然后使用$ locationProvider。$ get()。
$ location服務在Angular完全引導之前不可用,因為僅在應用程序的配置階段,服務才使用其相應的提供程序實例化。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.