angular bootstrap lightbox抛出未知的提供程序错误

时间:2016-04-27 07:59:01

标签: angularjs bootstrap-lightbox angularbootstrap-lightbox

是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);
        };
    });

但是每当我访问图库页面时,它总会抛出未知的提供程序错误,此错误将指向Lightbox中提到的$scope参数以及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)

1 个答案:

答案 0 :(得分:2)

您需要将注入galleryController的依赖项从LightBox更改为Lightbox。 (B未在Lightbox中大写。)这解决了问题。