Angular collection that works with ng-repeat and other cool features
- include module 'labsCollection'
- inject '$labsCollection'
angular.module('myApp',['labsCollection'])
.controller('myController', ['$labsCollection', function ('$labsCollection') {
}]);
- 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
var myCollection = $labsCollection.create()
var myCollection = $labsCollection.create({
url: '/query',
autoLoad: true //optional
})
var myCollection = $labsCollection.create({
httpConfig: {
url:'/query',
method:'GET',
transformResponse: function (data) {
return data;
},
transformRequest: function (data) {
},
responseType:'json'
},
autoLoad: true //optional
})
var resouce = new $resource('/some/url');
var myCollection = $labsCollection.create({
ngResource: resource,
autoLoad: true //optional
})