AngularJS service for prismic.io.
You can download it manually by clicking here to download development unminified version or here to download minified production version
First you need to configure the PrismicProvider
. You can configure the following parameters where the API Endpoint is mandatory.
- API Endpoint (
setApiEndpoint
) - Access token if the Master is not open (
setAccessToken
) - OAuth (
setClientId
,setClientSecret
) - Links resolution rules (
setLinkResolver
)
You can configure the PrismicProvider
in the config
var app = angular.module('app', ['prismic.io']);
app.config(function(PrismicProvider) {
PrismicProvider.setApiEndpoint('https://lesbonneschoses.prismic.io/api');
PrismicProvider.setAccessToken('');
PrismicProvider.setClientId('');
PrismicProvider.setClientSecret('');
PrismicProvider.setLinkResolver(function(ctx, doc) {
return 'detail.html?id=' + doc.id + '&slug=' + doc.slug + ctx.maybeRefParam;
});
});
As soon as the above is done you are ready to inject PrismicProvider
in your services and controllers:
app.controller('AppCtrl', ['Prismic', function(Prismic) {
var self = this;
Prismic.all().then(function(data) {
self.data = data;
});
}]);
These are the methods that can be called on the Prismic
object:
Prismic.all()
Prismic.query(predicateBasedQueryString)
Prismic.document(idString)
Prismic.documents(idsArray)
Prismic.bookmark(bookmarkString)
Or for more advanced queries using the underlying objects of the JS kit:
Prismic.api()
Prismic.ctx()
The prismicHtml-directive can be used as follows
<prismic-html fragment="data.fragment"></prismic-html>
where 'fragment' is a prismic.io type/value object.
New contributions are always welcomed. Just open a pull request making sure that it contains tests and documentation updates.
MIT