我已经在这工作了大约5个小时,而且我不确定我做错了什么。代码是从http://compact.github.io/angular-bootstrap-lightbox/demo6/新复制到角色和卡住的。
这就是我在控制器中所拥有的:
'use strict';
angular.module('portfolio.photography',[
'bootstrapLightbox',
'ngRoute'
])
.config(['$routeProvider', function($routeProvider) {
$routeProvider.when('/photography', {
templateUrl: 'photography/photography.html',
controller: 'PhotographyCtrl'
});
}])
.controller('PhotographyCtrl',[
'$scope', function($scope, Lightbox) {
$scope.openLightboxModal = function (index) {
Lightbox.openModal($scope.images, index);
};
}])
这是我得到的错误:
angular.js:14199 TypeError:无法读取属性' openModal'未定义的
答案 0 :(得分:0)
您错过了在括号中添加Ligthbox注入
['$scope', 'Lightbox', function($scope, Lightbox){}]
<强>更新强> 我根据你的需要创建了一个需要工作的所有依赖项的plnkr,我认为你需要包含ui-bootstrap依赖项。看看这个