How to use the ngx-jsonapi.DocumentResource function in ngx-jsonapi

To help you get started, we’ve selected a few ngx-jsonapi examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github reyesoft / ngx-jsonapi / demo / app / books / books.service.ts View on Github external
import { Injectable } from '@angular/core';
import { Autoregister, Service, Resource, DocumentCollection, DocumentResource } from 'ngx-jsonapi';
import { Author } from '../authors/authors.service';
import { Photo } from '../photos/photos.service';

export class Book extends Resource {
    public attributes = {
        date_published: '',
        title: '',
        created_at: '',
        updated_at: ''
    };

    public relationships = {
        author: new DocumentResource(),
        photos: new DocumentCollection()
    };
}

@Injectable()
export class BooksService extends Service {
    public resource = Book;
    public type = 'books';
    public ttl = 1;

    // executed before get data from server
    public parseFromServer(attributes): void {
        attributes.title = '📖 ' + attributes.title;
    }

    // executed before send to server

ngx-jsonapi

JSON API library for Angular

MIT
Latest version published 6 months ago

Package Health Score

66 / 100
Full package analysis