bower install k88hudson/makeapi-angular
<link rel="stylesheet" href="bower_components/makerstrap/dist/makerstrap.complete.min.css" />
angular.js
, makeapi-client.js
, makeapi-angular.js
and makapi-angular.templates.js
are all added to your document.
wmMakeApiAngular
module to your angular app.
To create an individual make, just add a make
element with make-id
and user-id
attributes.
<make make-id="539f56c3522cf67163000154" user-id=""></make>
controller('yourController', ['$rootScope', '$scope',
function ($rootScope, $scope) {
function init() {
$scope.userId = $rootScope._user.id;
}
init();
}
])
To create a gallery of makes, use a make-gallery
element (or attribute):
<make-gallery
tags="['puppy']"
user-id=""
container-class="col-sm-3">
</make-gallery>
Make galleries have the following optional attributes:
limit
[number] - This max number of makes. The default is 20.tags
[array] - An array of tagsids
[array] - An array of idsmakeList
[string] - An id of a [makeList](http://mozilla.github.io/makeapi-docs/client-docs/#get-list)container-class
[string] - Classes to be added to each make's container elementIn webmaker, you can use make galleries with Masonry:
Just give the masonry-gallery
attribute to an element and put the masonry options (documented here) in the data-masonry-options
attribute. Then, add makes as normal:
<div masonry-gallery data-masonry-options='{"itemSelector": ".sample-make", "gutter": 10, "columnWidth": 300}'>
<make class="sample-make" user-id="" make-id="539f57af553a77203f000173"></make>
<make class="sample-make" user-id="" make-id="5400dad39f2f4aac36000003"></make>
<make class="sample-make" user-id="" make-id="5400dae29f2f4aac36000004"></make>
<make class="sample-make" user-id="" make-id="5400daf59f2f4aac36000005"></make>
</div>
They should automatically be masonry-fied thanks to the masonryGallery directive.
Included in this module is the makeApi
service.
You should use it just like the normal makeapi-client except instead of using the final function `.then()`, use `.get()` instead.
.get()
returns a promise that can be resolved just like $http
's get
, i.e. with the functions .success()
and .error()
:
makeApi
.tags(['puppy'])
.limit(10)
.get()
.success(data) {
console.log(data);
})
.error(err) {
console.error(err);
});