A contentful.js wrapper for Angular w/ request caching
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Failed to load latest commit information.
demo Update demo with loader Oct 31, 2017
e2e chore: initial commit from @angular/cli Oct 26, 2017
src Export service so that apps can use it Nov 17, 2017
.angular-cli.json chore: initial commit from @angular/cli Oct 26, 2017
.editorconfig chore: initial commit from @angular/cli Oct 26, 2017
.gitignore chore: initial commit from @angular/cli Oct 26, 2017
LICENSE A license to thrill Oct 27, 2017
README.md Update version of Contentful to 5.0.5. Nov 17, 2017
karma.conf.js chore: initial commit from @angular/cli Oct 26, 2017
ng-package.json First bite of the apple Oct 27, 2017
package.json Fix vulnerability in package-lock file Mar 21, 2018
protractor.conf.js chore: initial commit from @angular/cli Oct 26, 2017
public_api.ts First bite of the apple Oct 27, 2017
tsconfig.json chore: initial commit from @angular/cli Oct 26, 2017
tslint.json chore: initial commit from @angular/cli Oct 26, 2017


GitHub release GitHub license GitHub issues Twitter

Angular Contentful Service

A contentful.js wrapper for Angular that makes our lives just a bit easier. Also, requests to the Contentful API are cached for improved performance!


Install with NPM

npm i --save angular-contentful-service

Install contentful

If you haven't already, make sure you install contentful

npm i --save contentful

Add to your app module

import { BrowserModule } from '@angular/platform-browser';
import { NgModule } from '@angular/core';
import { AppComponent } from './app.component';
import { ContentfulModule } from 'angular-contentful-service';

  declarations: [
  imports: [
      space: 'yadj1kx9rmg0', // your space ID
      accessToken: 'fdb4e7a3102747a02ea69ebac5e282b9e44d28fb340f778a4f5e788625a61abe', // your access token
  bootstrap: [AppComponent]
export class AppModule { }

Use the Contentful Service

import { Component } from '@angular/core';
import { ContentfulService } from 'angular-contentful-service'

  selector: 'app-root',
  templateUrl: './app.component.html',
  styleUrls: ['./app.component.css']
export class AppComponent {

  constructor(private cs: ContentfulService) {}

  getEntries(query?: any) {
    this.cs.getEntries(query).then(res => console.log(res));

  getEntry(id: string, query?: any) {
    this.cs.getEntry(id, query).then(res => console.log(res));

Configuration options

  space: string;
  accessToken: string;
  insecure?: boolean;
  host?: string;
  basePath?: string;
  httpAgent?: any;
  httpsAgent?: any;
  proxy?: {
    host: string;
    port?: number;
    auth?: {
      username: string;
      password: string;
  headers?: any;
  application?: string;
  integration?: string;
  resolveLinks?: boolean;
  retryOnError?: boolean;

Service methods


Return all entries filtered by Contentful query

getEntries(query?: any): Promise<EntryCollection<any>>

Information on EntryCollection type found here: https://github.com/contentful/contentful.js/blob/master/index.d.ts#L34


this.cs.getEntries({include: 2});


Return a single entry object based on id and optional query params

getEntry(id: string, query?: any): Promise<Entry<any>>

Information on Entry type found here: https://github.com/contentful/contentful.js/blob/master/index.d.ts#L65


this.cs.getEntry('3xd57HfJlSM2qmm8C6cueK', {include: 2})


Please feel free to contribute to this repository. To do so, simply clone this repository and run ng serve to get the project working locally.

Brought to you by

Use All Five