AngularJs Picture Gallery Module Showing angular powers
install guide :
- make sure angular-bootstrap is included in your project.
- add the picture-gallery.js and css files to the project.
- drop the image files in ../images.
- add 'ng-pictureGallery' to your app dependencies
congrats you now have ng-pictureGallery in your project
usage :
in your view.html file add the following tag
<my-gallery collection="" url="" pagesizes="" defaultsize=""/>
the directive accepts 4 attributes :
- collection : creates an isolated scope and bind to a collection in your controller
- url : the url for your images ('http://route/to/my/images.json
- pagesizes : sets pages sizes for paging accepts array (default is [5,10,15,20])
- defaultsize : sets default page size (default is 10)
the directive can be used in 2 ways :
-
just specify a url and let the magic happen.
-
consume the gallerySrv service in your controller and invoke the getImages() method (returns promise), in the markup specify the collection on your controller you wish to bind to (collection="myCollection").
there is also a build-in controller called 'galleryController'.
example controller :
angular.module('galleryApp').controller('aCtrl', function($scope, gallerySrv) {
$scope.images = [];
$scope.url = 'path/to/images';
gallerySrv.getImages(url).then(function(data) {
$scope.images = data;
});
});
<my-gallery collection="images"/>