1

我是AngularJS的新手,並試圖學習東西。我正嘗試創建一個帶有angular-bootstrap-lightbox的圖庫,並且我已經包含了該項目所需的所有必需依賴項。包括依賴關係是:角引導燈箱拋出未知提供者錯誤

<link href="css/angular-bootstrap-lightbox.min.css" rel="stylesheet" /> 
<script src="js/angular.js"></script> 
<script src="js/angular-route.min.js"></script> 
<script src="js/ui-bootstrap-tpls-1.3.2.min.js"></script> 
<script src="js/angular-bootstrap-lightbox.min.js"></script> 
<script src="js/script.js"></script> 

下面是我的script.js文件

angular.module('home', ["ngRoute", "bootstrapLightbox"]). 
    config(function ($routeProvider, $locationProvider) { 
     $routeProvider. 
      when('/home', { templateUrl: 'partials/home.html' }). 
      when('/about', { templateUrl: 'partials/about.html' }). 
      when('/gallery', { templateUrl: 'partials/gallery.html', controller: "galleryController" }). 
      otherwise({ redirectTo: '/home', templateUrl: 'partials/home.html' }); 
     $locationProvider.html5Mode(true); 
    }).controller("homeController", function ($scope, $http, $route) { 
     //home controller stuffs 
    }).controller('indexController', function ($scope, $location) { 
     $scope.isActive = function (route) { 
      return route === $location.path(); 
     } 
    }).controller('galleryController', function ($scope, LightBox) { 
     $scope.images = [ 
     { 
      'url': 'images/g1.jpg', 
      'caption': 'Optional caption', 
      'thumbUrl': 'images/g1.jpg' // used only for this example 
     }, 
     { 
      'url': 'images/g1.jpg', 
      'thumbUrl': 'images/g1.jpg' 
     }, 
     { 
      'url': 'images/g1.jpg', 
      'thumbUrl': 'images/g1.jpg' 
     } 
     ]; 

     $scope.openLightboxModal = function (index) { 
      Lightbox.openModal($scope.images, index); 
     }; 
    }); 

但它總是拋出未知的提供程序錯誤每當我參觀畫廊頁面,這個錯誤將指向與$scope沿提到Lightbox參數在galleryController。不知道這裏的依賴是什麼。但它不承認LightBox。我遵循了上面提到的完整步驟,但無法完全實現這一權利。任何幫助讚賞。

更新

以下是錯誤我得到。

angular.js:13424 Error: [$injector:unpr] Unknown provider: LightBoxProvider <- LightBox <- galleryController 
http://errors.angularjs.org/1.5.3/$injector/unpr?p0=LightBoxProvider%20%3C-%20LightBox%20%3C-%20galleryController 
    at http://ajax.googleapis.com/ajax/libs/angularjs/1.5.3/angular.js:68:12 
    at http://ajax.googleapis.com/ajax/libs/angularjs/1.5.3/angular.js:4418:19 
    at Object.getService [as get] (http://ajax.googleapis.com/ajax/libs/angularjs/1.5.3/angular.js:4571:39) 
    at http://ajax.googleapis.com/ajax/libs/angularjs/1.5.3/angular.js:4423:45 
    at getService (http://ajax.googleapis.com/ajax/libs/angularjs/1.5.3/angular.js:4571:39) 
    at injectionArgs (http://ajax.googleapis.com/ajax/libs/angularjs/1.5.3/angular.js:4595:58) 
    at Object.instantiate (http://ajax.googleapis.com/ajax/libs/angularjs/1.5.3/angular.js:4637:18) 
    at $controller (http://ajax.googleapis.com/ajax/libs/angularjs/1.5.3/angular.js:10042:28) 
    at A.link (http://localhost:63211/js/angular-route.min.js:18:216) 
    at invokeLinkFn (http://ajax.googleapis.com/ajax/libs/angularjs/1.5.3/angular.js:9623:9) <ng-view class="ng-scope">(anonymous function) @ angular.js:13424 
http://localhost:63211/gallery Failed to load resource: the server responded with a status of 404 (Not Found) 
+0

你可以創建一個plunker,http://plnkr.co/edit – dreamweiver

+0

@dreamweiver ..對不起,但不知道如何我可以在plunker複製這..但這裏是如何** [''設計外觀']( http://plnkr.co/edit/gq1HwIi2iVUeEAgpoizv?p=preview)** –

回答

2

你需要改變注入galleryControllerLightBoxLightbox的依賴。 (B在Lightbox中沒有大寫。)解決了這個問題。

+0

是的..這樣一個愚蠢的錯誤..感謝解決它的朋友.. :) –

+0

嗯,我沒有拼寫錯誤,所以。 ..搜索繼續:D –

相關問題