-1
angular.module('birdsApp.controllers', ['bootstrapLightbox']);
angular.module('birdsApp.controllers', []).
controller("birdssController", ['$scope','$http', function($scope, $http, Lightbox)
{
$scope.nameFilter = null;
$scope.searchFilter = function (writer) {
var keyword = new RegExp($scope.nameFilter, 'i');
return !$scope.nameFilter || keyword.test(birdfinder[1]);
};
$http.get('app/demo2.txt?callback=JSON_CALLBACK').success (function(data,index){
$scope.birdfinderlist = data.aaData;
console.log(index);
console.log(data.aaData[1].list[1].bird_img);
//$scope.birdfinderlist2 = data.aaData.list;
//console.log(data.aaData[1].list.bird_englishname);
$scope.openLightboxModal = function (index) {
//Lightbox.openModal($scope.images, index);
console.log(data.aaData[1].list[1].bird_img);
Lightbox.openModal(data.aaData[1].list[1].bird_img, index);
};
});
// $scope.openLightboxModal = function (index) {
// Lightbox.openModal(index);
// }
}
]
);
プロジェクトの画像をクリックするときにライトボックスを追加したいと思い、既存のコードに次のラインコードを追加しました。別のアングルライトボックスプラグを実装する際の角型JSの問題
angular.module('birdsApp.controllers', ['bootstrapLightbox']);
&
$scope.openLightboxModal = function (index) {
//Lightbox.openModal($scope.images, index);
console.log(data.aaData[1].list[1].bird_img);
Lightbox.openModal(data.aaData[1].list[1].bird_img, index);
};
しかし、その投げ次のエラーが
angular.js:5765 TypeError: Cannot read property 'openModal' of undefined
at Object.$scope.openLightboxModal (http://192.168.0.200:81/rnd/angular/all_birds/js/controllers.js:62:21)
at http://192.168.0.200:81/rnd/angular/all_birds/bower_components/angular/angular.js:6393:19
at http://192.168.0.200:81/rnd/angular/all_birds/bower_components/angular/angular.js:13268:13
at Object.$eval (http://192.168.0.200:81/rnd/angular/all_birds/bower_components/angular/angular.js:8153:28)
at Object.$apply (http://192.168.0.200:81/rnd/angular/all_birds/bower_components/angular/angular.js:8233:23)
at HTMLAnchorElement.<anonymous> (http://192.168.0.200:81/rnd/angular/all_birds/bower_components/angular/angular.js:13267:17)
at http://192.168.0.200:81/rnd/angular/all_birds/bower_components/angular/angular.js:1980:10
at Array.forEach (native)
at forEach (http://192.168.0.200:81/rnd/angular/all_birds/bower_components/angular/angular.js:154:11)
at HTMLAnchorElement.eventHandler (http://192.168.0.200:81/rnd/angular/all_birds/bower_components/angular/angular.js:1979:5)(anonymous function) @ angular.js:5765(anonymous function) @ angular.js:4812$apply @ angular.js:8235(anonymous function) @ angular.js:13267(anonymous function) @ angular.js:1980forEach @ angular.js:154eventHandler @ angular.js:1979
controllers.js:61 https://upload.wikimedia.org/wikipedia/commons/thumb/2/27/Podiceps_cristatus_2_-_Lake_Dulverton.jpg/220px-Podiceps_cristatus_2_-_Lake_Dulverton.jpg
私の既存の実施例は、ここに
http://mraje.in/angular/all_birds/index.html
&です編集したエラーページはこちら
http://mraje.in/angular/all_birds/index2.html
へ
私は、このしかし、ここで別のエラーを投げ http://mraje.in/angular/all_birds/index2.html –
を追加しているあなたが含まましたライトボックスのインデックスのソース?? angular.module( 'birdsApp.controllers'、['bootstrapLightbox'])。 コントローラ( "birdssController"、['$ scope'、 '$ http'、 'ライトボックス'、function($ scope、$ http、Lightbox) { –
ここからプラグインをダウンロードしました。http://compact.github。 io/angular-bootstrap-lightbox/demo1/ –