How to use ngx-jsonapi - 5 common examples

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
    public parseToServer(attributes): void {
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
github reyesoft / ngx-jsonapi / demo / app / authors / authors.service.ts View on Github external
import { Injectable } from '@angular/core';
import { Autoregister, Service, Resource, DocumentCollection } from 'ngx-jsonapi';
import { Book } from '../books/books.service';
import { Photo } from '../photos/photos.service';

export class Author extends Resource {
    public attributes = {
        name: 'default name',
        date_of_birth: '',
        date_of_death: '',
        created_at: '',
        updated_at: ''
    };

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

@Injectable()
export class AuthorsService extends Service {
    public resource = Author;
    public type = 'authors';
}
github reyesoft / ngx-jsonapi / demo / app / authors / authors.service.ts View on Github external
import { Autoregister, Service, Resource, DocumentCollection } from 'ngx-jsonapi';
import { Book } from '../books/books.service';
import { Photo } from '../photos/photos.service';

export class Author extends Resource {
    public attributes = {
        name: 'default name',
        date_of_birth: '',
        date_of_death: '',
        created_at: '',
        updated_at: ''
    };

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

@Injectable()
export class AuthorsService extends Service {
    public resource = Author;
    public type = 'authors';
}
github reyesoft / ngx-jsonapi / demo / app / app.module.ts View on Github external
loadChildren: './authors/authors.module#AuthorsModule'
    },
    {
        path: 'books',
        loadChildren: './books/books.module#BooksModule'
    }
];

@NgModule({
    providers: [AuthorsService, BooksService, PhotosService],
    imports: [
        BrowserModule,
        HttpClientModule,
        SharedModule,
        RouterModule.forRoot(appRoutes, { useHash: true }),
        NgxJsonapiModule.forRoot({
            url: environment.jsonapi_url
        })
    ],
    declarations: [AppComponent],
    bootstrap: [AppComponent]
})
export class AppModule {}

ngx-jsonapi

JSON API library for Angular

MIT
Latest version published 5 months ago

Package Health Score

68 / 100
Full package analysis