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 –

相关问题