Skip to content

bertramdev/ng-labs-collection

Repository files navigation

ng-labs-collection Build Status

Angular collection that works with ng-repeat and other cool features

Usage

  • include module 'labsCollection'
  • inject '$labsCollection'

example

angular.module('myApp',['labsCollection'])
	.controller('myController', ['$labsCollection', function ('$labsCollection') {

}]);

Options

  • idAttr: the id attribute of the objects you are adding (defaults to id)
  • url: the url to use to load remote data
  • httpConfig: the standard $http config object to be used to load remote data
  • ngResource: the non instanciated version of your resource
    • the collection will use the query function for paging
  • autoLoad: will load the first page if loading remote data (defaults to false)
  • arrayProp: used to find the array of items in a response object (defaults to data)
  • totalProp: used to find the property of a response object that contains the total count of items (defaults to total)
  • pageAttr: the attribute name to use when making a call to get more data (defaults to page)
  • pageSizeAttr: the attribute name to use when making a call to get more data (defaults to pageSize)
  • keepAll: keeps all items in another collection when loading items remotely (defaults to false)
  • pageSize: the number of items per page (defaults to 10)
    • use 'ALL' to no use any page attributes

Examples

Basic usage:

	var myCollection = $labsCollection.create()

Simple Remote loading:

	var myCollection = $labsCollection.create({
    	url: '/query',
        autoLoad: true //optional
    })

Complex Remote loading:

	var myCollection = $labsCollection.create({
    	httpConfig: {
			url:'/query',
			method:'GET',
			transformResponse: function (data) {
				return data;
			},
			transformRequest: function (data) {

			},
			responseType:'json'
		},
        autoLoad: true //optional
    })

ngResource:

	var resouce = new $resource('/some/url');
	var myCollection = $labsCollection.create({
    	ngResource: resource,
        autoLoad: true //optional
    })

About

Angular collection that works with ng-repeat and other cool features

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published